码迷,mamicode.com
首页 > 系统相关 > 详细

shell read 文件

时间:2018-11-17 12:01:05      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:root   one   cat   echo   bin   this   变量   localhost   name   

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 文件

标签:root   one   cat   echo   bin   this   变量   localhost   name   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!