Accessing variables of one shell script in another shell script

Hi All,

I have a shell script called sample1.sh where I have 2 variables. Now I have another shell script called sample2.sh. I want the variables in sample1.sh to be available to sample2.sh.

For example. In sample1.sh I am finding the sum of 2 numbers namely a and b. Now I want to access these variables in sample2.sh. Is this possible? How can I do this?

Thanks in advance.

sample2.sh

. sample1.sh
.....

If you have only variables in sample1.sh, then you can use above code, else keep all the variables in one file and replace sample1.sh by that file name in above code.

export the variable u want to use

eg export var1

If value of var1 is set in 1.sh u can use the value of var1 in 2.sh