管道符是 fork 子进程, 子进程的变量无法传回父进程
- [[email protected] ~]# echo "1 2 3" | read a b c;echo $a
- [[email protected] ~]# echo "1 2 3" | {
- read a b c;echo $a;
- }
- 1
read 放到前面来
[[email protected] ~]# read a b c <<< "1 2 3"
来源: http://www.bubuko.com/infodetail-3458771.html