1

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?

Hamzsé
  • 11
  • 1
  • 2
    [Gilles's answer](https://unix.stackexchange.com/a/212298/70524) describes what's happening: by the time the remote shell runs it, it looks like `sh -c echo hello; echo world`, `sh -c echo hello` runs `echo` without arguments (`hello` is `$0` for `sh -c`), and `echo world`, so you get the empty line and `world`. – muru Mar 14 '21 at 18:36

0 Answers0