首页 > 系统服务 > 详细

shell read 文件

时间:2018-11-17 11:46:29      阅读:158      评论:0      收藏:0      [点我收藏+]
cat filename.txt |while read LINE
do
        echo $LINE
done
# LINE在这里面只是随便一个变量,并不是内置

或者

#!/bin/bash

while read aa
do
        echo $aa
done< filename.txt
#这种格式看起来更好
#!/bin/bash
myfile=filename.txt
count=0

cat $myfile |while read LINE
do
        echo $LINE
        let count=count+1
        echo $count line
done

  

[root@localhost prog]# cat filename.txt This is line number 1 This is line number 2 This is line number 3 This is line number 4 This is line number 5 This is line number 6 This is line number 7 This is line number 8 This is line number 9 This is line number 10

  

shell read 文件

原文:https://www.cnblogs.com/uxiuxi/p/9973184.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!