bashrsh

Escaping pipe character in rsh


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

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

Getting:

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

bash: 789: command not found

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

Thanks!


Solution

  • Just escape the pipes and the quotes:

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