file1 include.sh
#!/bin/bash
var1="Hello there"
file2 includetest.sh
#!/bin/bash
. include.sh
echo $var1
#file2 has access to all variables defined in file1
>>>>Run file2 and you see the required output.
>>chmod +x includetest.sh
>>./includetest.sh
No comments:
Post a Comment