2

I have the following file called as test1.sh which contains:

File 1: test1.sh

#!/bin/bash

a=10
b=11
if [ $a == $b ]
then
    message="A is equal to b"
else
    message="A is not equal to b"
fi

Note: Now i have second file called as test2.sh in which i want to print the message variable of file one that is test1.sh.

File 2: test2.sh

#!/bin/bash
.... /*How to get the message variable from file test1.sh */
echo $message
2
  • Have you tried searching stackoverflow.com, rather than posting a new question here, as it doesn't directly concerns Ubuntu? – whtyger Mar 8 '16 at 12:44
  • 2
    How are you going to run the two scripts? What's their relation? – techraf Mar 8 '16 at 12:44
2

You need to source. (I assume that both files are in the same location)
In test2.sh add . test1.sh

Not the answer you're looking for? Browse other questions tagged or ask your own question.