测试文件:
测试的相关代码:
#!/bin/bash
while read line
do
echo $line
done < test.txt
#!/bin/bash
cat test.txt | while read line
do
echo $line
done
在文件夹中加入test.txt和homework.sh
切换到此文件夹
执行方式1:
chmod +x ./homework.sh
./homework.sh
执行方式2:
bash homework.sh
测试结果
来源:CSDN
作者:you_lxy
链接:https://blog.csdn.net/qq_43148490/article/details/104768314