2 ms·
If you use bash on both sides, you can use printf for any words in the command that need quoting (or all words if you are writing a script): ssh foo@bar ba
by aidenn0 3y ago
If you use bash on both sides, you can use printf for any words in the command that need quoting (or all words if you are writing a script):
ssh foo@bar baz "$(printf '%q\n' "something that needs $quoting")
For cases where one or both sides are not bash, but still POSIX like, it's relatively easy to write a function that uses single quotes; just replace every single quote with '\'' before wrapping in single quotes.