Newbie bash scripts and aariables question

Jordon Bedwell jordon at
Thu Oct 7 18:22:26 UTC 2010

On Thu, 2010-10-07 at 13:55 -0400, Maxime Alarie wrote:
> I would like to call Script B from Script A, and I want Script B to
> access Script A’s variables.Do I have to do a include ./Script_A in
> Script B?


export THIS_VARIABLE = "Hello world"
echo "Script one says $THIS_VARIABLE"

echo "Script two says $THIS_VARIABLE"

Use "export" to push it to the environment

To pass variables between SH scripts you either need to export them into
the environment or you could use STDOUT to STDIN but that's just not
viable for simple scripts really.  You could also just do something like

THIS_VARIABLE = "Hello World"
echo "Script one says $THIS_VARIABLE"
./script2.bash $THIS_VARIABLE

echo "Script two says $1"

Good luck BASH scripting!

More information about the ubuntu-users mailing list