shell-4:while和for讀取文件

while能一行一行的讀
[root@a lmk]# cat line.txt
1 1
2 2
3 3
4 4
[root@a lmk]# cat read.sh
#!/bin/basebash

cat line.txt |
while read line
do
echo $line
sleep 1
done
[root@a lmk]# sh read.sh
1 1
2 2
3 3
4 4
for 有bug
[root@a lmk]# cat line.txt
1 1
2 2
3 3
4 4
[root@a lmk]# cat read.sh
#!/bin/bash
for i in cat line.txt
do
echo $i
done
[root@a lmk]# sh read.sh
1
1
2
2
3
3
4
4ide

相關文章
相關標籤/搜索