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 Answer 1

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;"

1
  • Or use single quotes: /bin/sh -c 'X=1; echo $X'. Jun 27, 2017 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .