I have a problem that I've come up with a reasonably nice solution for, but have been going over it in my head and wondering if it's the best solution.
I have a log file in which I want to hide file and path names. I want to preserve the appearance of a directory structure, so I do not want to hide the "/" characters that are used as directory separators.
The filename will always appear at most once per line, and will always appear inside of an easily identifiable section, like this: file="path/goes/here".
I would like to process that example so that the output looks like this: file="xxxx/xxxx/xxxx".
The solution that I came up with does exactly what I want. From the command line, I pipe it to this (this is on a Unix host):
I've been wondering if there is something simpler, like somehow being able to do s|[^/]|x|g on the text between file=" and ", but I haven't been able to figure out how.... | perl -pe '1 while s|(file="[x/]*)[^x/"]|$1x|;'
Does anyone have any suggestions?
In reply to Selectively replacing characters inside a string by markkawika
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |