0

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

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'. – Kamil Maciorowski Jun 27 '17 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.