I am parsing command output and putting results into array.
Works fine until exiting the inner loop - output array is empty.
declare -a KEYS
#------
When you use a pipe (|
) to pass your command output to while
, your while
loop runs in a subshell. When the loop ends, your subshell terminates and your variables will not be available outside your loop.
Use process substitution instead:
while read line; do
# ...
done < <($glue_dir/get_keys $ip)