regex - using sed to replace a line with back slashes in a shell script -


i trying replace bottom 1 of these 2 lines sed in file.

    <rule>out_prefix=orderid ^1\\d\+ updatemtnotif/</rule>\n\     <rule>out_prefix=orderid ^2\\d\+ updatemtnotif/</rule>\n\ 

and following command seems when executed command @ bash prompt

sed -i 's@out_prefix=orderid ^2\\\\d\\+ updatemtnotif/@out_prefix=orderid ^2\\\\d\\+ updatemtnotif_fr/@g' /opt/temp/rules.txt 

however, when try execute same command remotely on ssh using here documents, command fails modify file. think escaping issue, have had no luck trying modify command in numerous ways. can 1 tell me should working on ssh? in advance!

to clarify,

input: <rule>out_prefix=orderid ^2\\d\+ updatemtnotif/</rule>\n\ output: <rule>out_prefix=orderid ^2\\d\+ updatemtnotif_fr/</rule>\n\ 

you can use ssh , heredoc this:

ssh -t -t user@localhost<<'eof' sed 's~out_prefix=orderid ^2\\\\d\\+ updatemtnotif/~out_prefix=orderid ^2\\\\d\\+ updatemtnotif_fr/~' ~/path/to/file exit eof 

ps: important quote 'eof' shown.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -