I have a select statement
sqlplus [credentials] select variable from table;
It returns 6 rows and I need to store them as an array in bash array variable.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With