When I execute /bin/sh -c "X=1;echo $X;"
it prints empty line. What am I doing wrong? My platform is macOS if it matters...
1 Answer
I think I have answer to my own question. It looks like variable is expanded before sh -c
is run. So I should have written /bin/sh -c "X=1; echo \$X;"
-
Or use single quotes:
/bin/sh -c 'X=1; echo $X'
. Commented Jun 27, 2017 at 11:34