Article 6KTW3 Remove trailing characters while adding leading characters

Remove trailing characters while adding leading characters

by
sharky
from LinuxQuestions.org on (#6KTW3)
Text file contains numerous strings with trailing sub-string.

example where _xx is the trailing sub-string;

Quote:
"m1_xx" some other text "m2_xx"
"p2_xx" yet more text "p2_xx" extra text
change is good "hello_xx"
desired output:

Quote:
"yy_m1" some other text "yy_m2"
"yy_p2" yet more text "yy_p2" extra text
change is good "yy_hello"
I found ways to make the substitution. However, with my method I lose the existing spacing - all the strings in the output are separated by a single space.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments