Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    A stricter, standard conformant way would be sh -c 'echo $1' echo foo Commented Jan 5, 2016 at 16:33
  • 1
    sh -c 'echo "$@"' fnord a b c d ... Commented Jan 5, 2016 at 17:43
  • 3
    IMHO the explanation was quite good, but sh -c 'echo $0' foo is not the best option, taking into account that the questioner already know that /bin/sh -c 'echo foo; echo bar' works, you can simply answer quoting the command /bin/sh -c 'echo foo' Commented Jan 5, 2016 at 18:01
  • 1
    @ X3MBoy The questioner already know that /bin/sh -c 'echo foo' works fine. He wanted to echo something outside that , which i explained Commented Jan 5, 2016 at 18:18
  • @IjazAhmadKhan what if I want to execute some command with sh -c something like this: sh -c test.py arg1 arg2 arg3 ? Secondly what if arg3 contains something like "/export/local/repo/ab#cd.rpm" , how can I handle # in this case ? Commented Apr 17, 2020 at 10:51