#! / bin / bash
while read line
do
echo-e "$ line / n"
done <file.txt
Need to add "<file.txt" after done, you'd better not to use "cat file.txt |while read line",
otherwise, it will invork a new subshell and will not exit from the while.
Here is the link for more detail info:
http://en.kioskea.net/faq/1757-how-to-read-a-file-line-by-line
关于while read line循环的linux bash shell bug
最新推荐文章于 2021-05-25 15:23:32 发布