首页 > 系统服务 > 详细

linux系统中 while read逐行读取数据

时间:2021-04-21 16:18:50      阅读:24      评论:0      收藏:0      [点我收藏+]

 

1、测试for  cat

[root@PC3 test]# cat a.txt
01 02 03
06 07 08
11 12 13
16 17 18
[root@PC3 test]# for i in `cat a.txt`; do echo $i ; done
01
02
03
06
07
08
11
12
13
16
17
18

 

2、测试while  read

[root@PC3 test]# cat a.txt
01 02 03
06 07 08
11 12 13
16 17 18
[root@PC3 test]# cat a.txt | while read i; do echo $i; done
01 02 03
06 07 08
11 12 13
16 17 18

while read  为逐行读取, 可基于此方法在每行传递多个参数。

 

linux系统中 while read逐行读取数据

原文:https://www.cnblogs.com/liujiaxin2018/p/14684772.html

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