For example, I have a main shell program main.sh
, and I have another subshell program sub.sh
. I want to pass a variable var to the subshell, but I do not want to use command-line argument. An example code is the following:
#In main.sh
a=1
./sub.sh
#In sub.sh
echo $a
I want to see the output: 1
I know this question is weird, but this feature best suits my need. I can't source the sub.sh
because in the actual program I have a LOT of variables to pass in... Thanks!
EDIT: What if I run sub.sh
in the backgroun and it takes 10 hours, and I want to run another sub.sh
in the foreground for another variable b
?