I've two configuration files, the original from the package manager and a customized one modified by myself. I've added some comments to describe behavior.
How can I run
diff on the configuration files, skipping the comments? A commented line is defined by:
- optional leading whitespace (tabs and spaces)
- hash sign (
- anything other character
The (simplest) regular expression skipping the first requirement would be
#.*. I tried the
-I RE) option of GNU diff 3.0, but I couldn't get it working with that RE. I also tried
.*\#.* without luck. Literally putting the line (
Port 631) as
RE does not match anything, neither does it help to put the RE between slashes.
As suggested in “diff” tool's flavor of regex seems lacking?, I tried
grep -G '#.*' file
This seems to match the comments, but it does not work for
diff -I '#.*' file1 file2.
So, how should this option be used? How can I make
diff skip certain lines (in my case, comments)? Please do not suggest
greping the file and comparing the temporary files.