I have to bash scripts:
script1.sh
HELLO=hello
export HELLO
./script2.sh
echo $HELLO
script2.sh
echo $HELLO
HELLO=world
export $HELLO
The output is hello hello instead of hello world. How can I modify variables between scripts which call each other?
EDIT: Passing variables as arguments won’t work. I don’t know the number of variables which might be changed in script2.sh.
If you do not want to run the second script as a child process, you have to source it:
No export is needed in the second script – you already told bash to export the variable.