How to store multiple row output in a bash array? How to store multiple row output in a bash array? bash bash

How to store multiple row output in a bash array?


array=(`sqlplus [credentials] select variable from table;`)echo ${array[*]}


If your variables contain spaces and you want the array to have an element for each line of output (as opposed to each word of output), you also need to set your IFS. And you may want to use quotes when using the array:

SaveIFS="$IFS"IFS=$'\n'array=( $(sqlplus [credentials] select variable from table;) )echo "${array[*]}"IFS="$SaveIFS"