Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想嵌套多个这样的字符串:
sudo ssh server "awk "/pattern/{print "hello"}1" file > file.tmp"
使用 2 个嵌套引号,我设法使我的命令有效:
awk "/pattern/{print \"hello\"}1" file > file.tmp
我不能使用单引号 ('),因为我的命令中有变量。有人能帮我吗 ?
提前致谢。
只要在远程服务器上的 shell 上执行整个命令字符串之前最初扩展变量,您仍然可以放置单引号。
sudo ssh server "echo \"$SOMEVAR\"; awk '/pattern/{print \"hello\"}1' file > file.tmp"