BDR*_*BDR 8 string bash shell command nested
我想嵌套多个字符串,如下所示:
sudo ssh server "awk "/pattern/{print "hello"}1" file > file.tmp"
Run Code Online (Sandbox Code Playgroud)
使用2个嵌套引号,我设法让我的命令工作:
awk "/pattern/{print \"hello\"}1" file > file.tmp
Run Code Online (Sandbox Code Playgroud)
我不能使用单引号('),因为我的命令中有变量.有人能帮我吗 ?
提前致谢.
kon*_*box 11
只要在远程服务器上的shell上执行整个命令字符串之前,最初要扩展变量,您仍然可以放置单引号.
sudo ssh server "echo \"$SOMEVAR\"; awk '/pattern/{print \"hello\"}1' file > file.tmp"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11632 次 |
| 最近记录: |