Possible Duplicate:How to “send” variable to sub-shell? I have a bash script and inside that script I do sh. How to pass a variable to the new shell? This is how it is (simplified to the specific problem):script.sh:#!/bin/bash#......MYVAR=myvaluesh -c 'some_code_here'#......Basically I want to use the MYVAR in my some_code_here part. I am thinking of creating a temp script and executing it. But if there's a simple way to pass, I can avoid temp script.
How to pass a variable to an sh child process?
bash;shell
Just export it:#!/bin/bashexport MYVAR=myvaluesh -c 'some_code_here'