I read the following posts regarding saving a multi line output to a variable assign the multiline output of command to a variable
I am not able to save each line into a different variable , I tried using an array but somehow the length of the array is always zero
my_array=()
cat check_status | while read line || [[ -n $line ]] ;
do
echo $line
my_array+=( $line)
done
echo ${#my_array[@]}
echo ${my_array[0]}
echo ${my_array[1]}
The length of the array is always 0 and the contents of the array are always blank
my output of cat is
alpha
beta
I want to save each of the line into a different variable. I am new to shell script so unsure if using array was the best solution here.