I have a log file with data I need to mask/replace.
Test file example
20120910:181649:TID=000ef4:Add :C155:E076:P: eTDYN-str-multi-109(String to replace)
20120910:181649:TID=000ef4:Add :C155:E076:P: eTDYN-str-multi-106(String to replace)
20120910:181649:TID=000ef4:Add :C155:E076:P: eTDYN-str-multi-104(String to replace)
20120910:181649:TID=000ef4:Add :C155:E076:P: eTDYN-str-multi-102(String to replace)
20120910:181649:TID=000ef4:Add :C155:E076:P: eTDYN-str-multi-18(String to replace)
It has many more of the eTDYN-str, 01-110.
I need to find each instance, one per line, and replace all of the text directly after it.
I was trying something like
perl -pie 's/^(eTDYN-str-multi-\d\d:\s+).*/$1<removed pii data>/g;' logtest.txt
I know it would only work for two digit numbers after the text, but it’s not even finding/replacing it.
Use sed to do something like:
This will match the literal “eTDYN-str-multi-” followed by one, two, or three digits, save that as “\1” and will match anything after that. Then it’ll replace the matched string with “\1” (the saved portion and of your choice.