$cat test
export var=value
$./test
$echo $var
I get nothing. I was expecting to see value.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your case
testis being run in a separate shell, a child of your shell. A child can never modify the environment of the parent. So when the child exitsvaris lost.If you want to run the script in the current shell try:
Also, it’s usually a poor idea to name your scripts “test”. Many unices have
/usr/bin/test.