写法一:输入重定向
1 #!/bin/bash 2 3 while read line 4 do 5 echo $line 6 done < file(待读取的文件)
写法二:管道命令
1 #!/bin/bash 2 3 cat file(待读取的文件) | while read line 4 do 5 echo $line 6 done
写法三:
1 for line in `cat file(待读取的文件)` 2 do 3 echo $line 4 done