Hi I have following example. a.sh script sets environment variable which I can see in b.sh (child) script, but if I change it I still have the old value in a.sh
a.sh
#!/bin/bash
export A=1
./b.sh
echo parent $A
b.sh
#!/bin/bash
echo child $A
A=2
export A
echo child $A
test:
bash-3.00$ ./a.sh
child 1
child 2
parent 1
child 1
child 2
In a.sh
do source b.sh
instead of ./b.sh
a.sh
should look like this :
#!/bin/bash
export A=1
source b.sh
echo parent "$A"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With