我是學習bash和我在互聯網上找到的教程,說這些是相同的:在「while read -r line; do ...; done <file`和`cat file | while IFS = read -r line; do ...; done`之間bash之間有任何區別嗎?
while read -r line;
do
...
done < file
$ cat file | while IFS= read -r line;
do
...
done
是否有在這兩個循環的任何細微的差別是它們真的一樣
我的建議:不要分析'cat'命令的輸出。 – 2014-10-20 17:41:10
爲了擴大chepner已經觸及的內容:一般來說'cat foo | bar「而不是'bar
2014-10-20 18:17:37
兩個循環都應該有'IFS ='? – 2014-10-20 18:53:03