Suresh
Suresh

Reputation: 1

How to turn off auto add escape character feature in Linux

I am trying to pass a command to a remote server using ssh. while my commands have some characters like ", $, ', \ which often requires a backslash as a escape character except ' (single quote), but the system is automatically taking an escape character \ before the single codes while execution. Can some one help me how to turn off this.

OS : RHEL

my Code :

ssh -q $server "ps -ef | grep mongo | grep conf | awk '{print \$(NF-2)}'

While execution, the code becomes

ssh -q $server "ps -ef | grep mongo | grep conf | awk \'{print $(NF-2)}\'"

I need to turn off this feature

Upvotes: 0

Views: 365

Answers (1)

tripleee
tripleee

Reputation: 189597

Your analysis isn't really correct. Anyhow, there is no particular reason to run Awk remotely, or grep at all here (because Awk does all of that nicely and efficiently with a very minor refactoring):

ssh -q "$server" ps -ef |
# This runs locally instead
awk '/mongo/ && /conf/ {print $(NF-2)}'

Upvotes: 1

Related Questions