shell:读取文件的每一行内容并输出

写法一:
#!/bin/bash
 
while read line
do
echo $line
done < file(待读取的文件)

写法二:

    
#!/bin/bash
 
cat file(待读取的文件) | while read line
do
echo $line
done

写法三:

for line in `cat file(待读取的文件)`
do
echo $line
done

以上三种写法都是我摘自网上的,共同分享一下。

http://blog.de3eb.cn/2012/03/shell%E8%AF%BB%E5%8F%96%E6%96%87%E4%BB%B6%E7%9A%84%E6%AF%8F%E4%B8%80%E8%A1%8C%E5%86%85%E5%AE%B9%E5%B9%B6%E8%BE%93%E5%87%BA/

原文地址:https://www.cnblogs.com/seasonzone/p/4683499.html