测试.txt:
1 1
2 2
3 3
测试.sh:
for ln in $(head -3 test.txt)
do
echo "New line: $ln";
done
我希望:
New line: 1 1
New line: 2 2
New line: 3 3
...但输出是:
New line: 1
New line: 1
New line: 2
New line: 2
New line: 3
New line: 3
变成:
"$(head -3 test.txt)"
...导致:
New line: 1 1
2 2
3 3
那有什么问题?显然,空间是问题所在。任何简单的解决方法?提前谢谢了。