美文网首页
shell读取文件的每一行

shell读取文件的每一行

作者: cain07 | 来源:发表于2021-07-15 23:55 被阅读0次

写法一:

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

写法二:

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

写法三:

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

for 逐行读会分割行内容

相关文章

网友评论

      本文标题:shell读取文件的每一行

      本文链接:https://www.haomeiwen.com/subject/rhvsaktx.html