I'm trying to get all results of jq query in a array in bash, but it gives me all results in the first array element. Could you help me? I would like to having every result in one array element
bash-4.2$ try=$(tm run jobs:status::get -s "tm=serverA&work=*&status=Failed" | $PATH_API/jq -r '.statuses[].name // empty')
bash-4.2$ echo $try
job_B job_C
bash-4.2$ echo "${#try[@]}"
1
bash-4.2$
variable=$(command)creates a string variable, not an array.declare -p tryinstead ofecho $trywill provide a more unambiguous readout of the variable's value. With your current value it should emitdeclare -- try="job_B job_C"; with a real array it would bedeclare -a try=( [0]=job_B [1]=job_C )