a=$(cat 1.sh)
等价于
a=`cat 1.sh`
而
a=(cat 1.sh) 相当于定义一个a数组,内容为cat 1.sh
a=(`cat 1.sh`)相当于把1.sh里面的内容当成a的数组,a仍旧是一个数组
a=$(`cat 1.sh`)此命令会报错,不能执行
[root@zejin240 chenzejin]# cat 1.sh
hello world 2016
better
[root@zejin240 chenzejin]# a=(cat .sh)
[root@zejin240 chenzejin]# b=(`cat .sh`)
[root@zejin240 chenzejin]# c=$(cat .sh)
[root@zejin240 chenzejin]# d=`cat .sh` [root@zejin240 chenzejin]# echo ${a[@]}
cat .sh
[root@zejin240 chenzejin]# echo ${b[@]}
hello world better
[root@zejin240 chenzejin]# echo ${c[@]}
hello world better
[root@zejin240 chenzejin]# echo ${d[@]}
hello world better [root@zejin240 chenzejin]# echo $a
cat
[root@zejin240 chenzejin]# echo $b
hello
[root@zejin240 chenzejin]# echo $c
hello world better
[root@zejin240 chenzejin]# echo $d
hello world better [root@zejin240 chenzejin]# e=$(`cat 1.sh`)
-bash: hello: command not found