首页 > 技术文章 > shell读取文件的每一行

fb010001 2020-04-24 11:25 原文

写法一:

!/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 逐行读会分割行内容

from
https://www.cnblogs.com/bob-coder/p/11502308.html

推荐阅读