Skip to main content
added info from comment
Source Link
Yaron
  • 4.4k
  • 2
  • 22
  • 33

Thanks for the below Note from @cas:
$b is NOT an array, it is a string containing "11 22"

The equivalent to

a=( 11 22 )

Is

b=($(echo "11 22"))

As a result

$ a=( 11 22 )
$ b=($(echo "11 22"))
$ echo $a
11
$ echo ${a[*]}
11 22
$ echo $b
11
$ echo ${b[*]}
11 22

The equivalent to

a=( 11 22 )

Is

b=($(echo "11 22"))

As a result

$ a=( 11 22 )
$ b=($(echo "11 22"))
$ echo $a
11
$ echo ${a[*]}
11 22
$ echo $b
11
$ echo ${b[*]}
11 22

Thanks for the below Note from @cas:
$b is NOT an array, it is a string containing "11 22"

The equivalent to

a=( 11 22 )

Is

b=($(echo "11 22"))

As a result

$ a=( 11 22 )
$ b=($(echo "11 22"))
$ echo $a
11
$ echo ${a[*]}
11 22
$ echo $b
11
$ echo ${b[*]}
11 22
Source Link
Yaron
  • 4.4k
  • 2
  • 22
  • 33

The equivalent to

a=( 11 22 )

Is

b=($(echo "11 22"))

As a result

$ a=( 11 22 )
$ b=($(echo "11 22"))
$ echo $a
11
$ echo ${a[*]}
11 22
$ echo $b
11
$ echo ${b[*]}
11 22