在Shell编程中使用管道进行循环时在,内部更改外部的变量时,无法生效
a=0
cat test.txt |
while read line
do
a=3
done
应该改为:
a=0
while read line
do
a=3
done < test.txt
同时注意:
参考:
https://blog.youkuaiyun.com/zhou16333/article/details/83796907
https://blog.youkuaiyun.com/Register_man/article/details/54376817