shell脚本按行读取文件的几种方式

1.

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

2.

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

3.

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

  

 

猜你喜欢

转载自www.cnblogs.com/lovemakee/p/10930371.html
今日推荐