bash 在 rsh 中转义管道字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15718756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 05:02:05  来源:igfitidea点击:

Escaping pipe character in rsh

bashrsh

提问by kirbo

I am trying to run this bash command, but I cant get around the "|" pipe character

我正在尝试运行此 bash 命令,但无法绕过“|” 管道字符

rsh -l user machine "echo "PORTS = 123|456|789" >> conf.cfg"

rsh -l user machine "echo "PORTS = 123|456|789" >> conf.cfg"

Getting:

获得:

bash: 456 >> conf.cfg: No such file or directory

bash: 456 >> conf.cfg: No such file or directory

bash: 789: command not found

bash: 789: command not found

Would you know how I can echo PORTS = 123|456|789into a remote file ?

你知道我如何回显PORTS = 123|456|789到远程文件中吗?

Thanks!

谢谢!

回答by fedorqui 'SO stop harming'

Just escape the pipes and the quotes:

只需转义管道和引号:

rsh -l user machine "echo \"PORTS = 123\|456\|789\" >> conf.cfg"