sh -c 'echo hello ; echo world'
Works fine on both host and remote machine, with the output of:
hello
world
but when I do
ssh username@remote sh -c 'echo hello ; echo world'
, then the output is:
world
Why did the command eat my first echo hello
command?
sh -c echo hello; echo world
,sh -c echo hello
runsecho
without arguments (hello
is$0
forsh -c
), andecho world
, so you get the empty line andworld
. – muru Mar 14 '21 at 18:36