Generated files often start with a timestamp or a version comment. Compare two of them and diff always reports a difference, even when nothing else changed.
diff -I '^# generated' old/app.conf new/app.conf
-I takes a regular expression. A change where every changed line matches it is ignored. Two files that only differ in their # generated 2026-11-29 line give no output and exit status 0. You can give -I more than once, for example for a date line and a build number.
I find it handy for comparing database dumps, exported router configs or anything else with a “made on” header.
The rule has a catch that surprises everyone. diff ignores a hunk only when all changed lines in it match. If the timestamp line sits right next to a real change, they end up in the same hunk, and diff shows both, the timestamp included. With the timestamp and a changed port number on the next line, both lines are printed. So the output isn’t wrong, it just isn’t as clean as you hoped.
Also, the pattern is checked against the full line, so keep it specific. A loose pattern like -I date can hide a real change in a line that happens to contain that word.
Further reading: diff(1) manual page, GNU diffutils manual