Bash - pass variables from one script to second one

10 points
Created by:

In this short article we would like to show how in Bash pass variables from one script to second one.

Quick solution (call child script following way):

. path/to/child/

Note: . exports all script variables to child script.

Practcal example

To see how it works we can use below example that needs to create in same directory 2 sh files.

Do following steps:

1. create scripts file:



echo " ${TEST}"

. ./ file:


echo " ${TEST}"

2. add execution permissions for files

chmod a+x
chmod a+x

3. run script


Output: 5 5
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé