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.

4
  • 2
    What's even better you can use && and || this way, too - echo test \&\& ls Commented May 14, 2019 at 17:51
  • 1
    @MiroKropacek That's nice, too. Better? Depends on what you want; run second command conditionally, then yes, run it unconditionally (no matter if first one succeeded or failed), then not... Commented May 14, 2019 at 19:24
  • 1
    @MiroKropacek, I didn't have to escape the && when putting double quotes around the commands: ssh host "echo test && ls" Commented May 8, 2020 at 15:50
  • 1
    Either quoting or backslashing is necessary but obviously not both, here (though there are situations where you do need to quote shell metacharacters from both the local and the remote shell). Commented Jan 15, 2022 at 12:20