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
----------------------------------------------------------------------------

posted @ 2017-12-04 09:30  爱吃橙子  阅读(7601)  评论(0编辑  收藏  举报