linux 中while循环中从文件中读取变量

 

001、

[root@pc1 test02]# ls
a.txt
[root@pc1 test02]# cat a.txt    ## 测试文件
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 16
17 18 19 20
[root@pc1 test02]# cat a.txt | while IFS= read i; do echo $i; done    ## 一种方式
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 16
17 18 19 20
[root@pc1 test02]# while IFS= read i; do echo $i; done < a.txt        ## 二种方式
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 16
17 18 19 20

 

posted @ 2023-09-12 23:53  小鲨鱼2018  阅读(83)  评论(0编辑  收藏  举报