I need to validate a file path that repeats often in a file.
All file path that begins with /usr/local must be /usr/local/test. Ignore rest of the file paths like /usr/tmp (or) /usr/logs etc.
The following should find any lines which contain strings which contain /usr/local
which do not match /usr/local/test
.
sed -n 's%/usr/local/test%%;\%/usr/local%p' filename
If you just want the line numbers, =
instead of p
does that.