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
MAK
  • 123

1 Answers1

2

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

muru
  • 207,228
EdiD
  • 4,617
  • 3
  • 27
  • 41