[shell] 一次性赋值多个变量
管道符是fork子进程,子进程的变量无法传回父进程
[root@XM-v106 ~]# echo "1 2 3" | read a b c;echo $a [root@XM-v106 ~]# echo "1 2 3" | { read a b c;echo $a; } 1 [root@XM-v106 ~]# echo $a;echo end end
read放到前面来
[root@XM-v106 ~]# read a b c <<< "4 5 6" [root@XM-v106 ~]# echo $a
4
[root@localhost ~]# read x y z < <(echo 4 5 6)
[root@localhost ~]# echo $y
5