in reply to Re^3: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?
in thread How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?

I am trying to use diff tool but use the -I option to ignore lines that start with "File Name:".i am using the below regular expression,there is no syntax error but the diff tool still shows changes with line that starts with "File Name:".Any idea what is going wrong?

diff -I '[^\s*File\sName:]' file1 file2
  • Comment on Re^4: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?
  • Download Code

Replies are listed 'Best First'.
Re^5: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?
by roboticus (Chancellor) on Feb 13, 2011 at 13:25 UTC

    iphone:

    If there are differences in comments, then it's likely that there will be differences in the whitespace as well, so tell diff to ignore blank lines and other forms of whitespace. I don't know what you're running on, but on my box here, I use the options:

    • -E to ignore tab expansion
    • -b to ignore changes in whitespace
    • -w to ignore all whitespace
    • -B to ignore blank lines

    Note: I've never experimented to see if I can get by with a subset of those flags, but I suspect I can. But it's easy, so I've never found it worth the time to find out.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re^5: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?
by Corion (Patriarch) on Feb 13, 2011 at 08:49 UTC

    Where does Perl come into play here?