I have a main script (main.bash)
#!/bin/bash
var=10 #Variable to pass to the nested script
./nested.bash $var #Pass 'var' to the nested script, which outputs the 'list' array
echo $list #echo the output of the nested script
The nested script (nested.bash) is:
#!/bin/bash
if [ $1 == 10 ] ; then
list=(10-10 20-01 30-03 40-01 50-05)
fi
export list
I used export, but it is not working. How can 'nested.bash' pass list array to 'main.bash'? More generally, how can this be done?