001、
[root@pc1 test]# ls a.txt [root@pc1 test]# cat a.txt ## 测试数据 1 2 3 [root@pc1 test]# sum=0 [root@pc1 test]# for i in $(seq 3); do let sum+=$i; done ## for循环,输出变量 [root@pc1 test]# echo $sum 6 [root@pc1 test]# sum=0 [root@pc1 test]# cat a.txt | while read i; do let sum+=$i; done ## while循环不能输出变量??? [root@pc1 test]# echo $sum 0
。
标签:##,差异,pc1,while,循环,test,root,sum From: https://www.cnblogs.com/liujiaxin2018/p/18108177