I'm using awk '{ gsub(/BAR|WIBBLE/, "FOO"); print }'
to replace text in data like:
SOMETHING [BAR, WIBBLE]
SOMETHING [BAR]
This gives the desired result of:
SOMETHING [FOO, FOO]
SOMETHING [FOO]
But now I've had to update the text that requires replacing to be something like:
awk '{ gsub(/BAR|WIBBLE|ME/, "FOO"); print }'
Which turns text like:
SOMETHING [ME, WIBBLE]
into:
SOFOOTHING [FOO, FOO]
How can I limit my replacement to just the text between the brackets (i.e. leave the SOMETHING
alone)?
EDIT
I also need robustness across whatever text SOMETHING
might be (e.g. SHE GAVE ME THAT
shouldn't have ME
replaced).
SOMETHING
should be. I'll update the question to make that clearer. – Chris Oct 24 '12 at 16:30