Reputation: 59
How to take the variable like this?
a.sh
#!/bin/sh
./b.sh
echo "The message is: $MESSAGE"
b.sh
#!/bin/sh
MESSAGE="hello"
Then run:
$ ./a.sh
The message is:
I want to take the value of variable MESSAGE in a.sh
How can I do?
Upvotes: 0
Views: 48
Reputation: 29266
If you do . ./b.sh
(or source b.sh
depending on your shell flavor) it will run b in the same shell as a rather than starting a different process.
Upvotes: 1