1

I'm trying to create a shell script that sets an environment variable and then calls another shell script which gets that environment variable. The following code is my attempt, but it's not producing the desired result...

scriptOne.sh

export MYVAR=blob                                                            
bash ./scriptTwo.sh

scriptTwo.sh

#!/bin/bash                                                                     
# SIMPLE                                                                        

printenv MYVAR <<END                                                            
ls || pwd && ls                                                                 
ls || ls | wc || pwd && ls                                                      
END                                                                             
echo
1
  • What does redirecting input to printenv do? Commented Nov 20, 2014 at 2:15

1 Answer 1

2

Try $MYVAR in scriptTwo.sh you need to add a dollar to expand a shell variable. I think you can call it using simply $ bash scriptTwo.sh btw.

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.