循环遍历文本文件每一行
- for循环
#这种方式,如果一行中有空格,那么空格后的会被截取为一段新行,while循环没有该问题
for line in `cat ./dir1/example.txt`
do
echo "line is $line"
done
- while循环
cat ./ibuild/channel.txt | while read line
do
echo $line
done
循环遍历文本文件每一行
#这种方式,如果一行中有空格,那么空格后的会被截取为一段新行,while循环没有该问题
for line in `cat ./dir1/example.txt`
do
echo "line is $line"
done
cat ./ibuild/channel.txt | while read line
do
echo $line
done
本文标题:循环遍历文件中每一行
本文链接:https://www.haomeiwen.com/subject/rimfjktx.html
网友评论