0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.