I want to nest multiple strings like this :
sudo ssh server "awk "/pattern/{print "hello"}1" file > file.tmp"
With 2 nested quotes I managed to make my command works :
awk "/pattern/{print \"hello\"}1" file > file.tmp
I cannot use single quote (') because there are variables in my command. Can someone help me ?
Thanks in advance.
You can still place single quotes as long as the variables are intended to be initially expanded before the whole command string is executed on the shell on the remote server.
sudo ssh server "echo \"$SOMEVAR\"; awk '/pattern/{print \"hello\"}1' file > file.tmp"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With