Tuesday, 15 May 2012

bash - Replace a string containing backslash using sed -


I want the option of a variable service SERVICE with a string $ service that has a backslash via the lead I did the following

  sed / ss / SERVICE / `printf '% q'" $ {service} "` / g '  

using this string I replaced To

  b_a ^ c_b _ \] wdd [] x \ [x [[w206c? 2 @, \\, A @ 2AW! W6 "|   

Where I want

  b_a ^ c_b _ \] wdd [] x \ [x \ [w206c? 2 @, \, a @ 2AW! W6 "|   

Is there any other way to do this? PS (string $ service has many different special characters)

You also do not use at all Instead, instead of:

  read -r; Echo "$ {REPLY // SERVICE / $ SERVICE}"    

No comments:

Post a Comment