cmdxray / commands / diff

What does diff do?

compare two files line by line and show the differences.

▸ Explain your own diff command →

diff examples, explained

$ diff -u old.txt new.txt

  • diffcompare two files line by line and show the differences
  • -uunified format — the diff style used by patches and git
  • old.txtan argument passed to the command
  • new.txtan argument passed to the command

$ diff -r dir1/ dir2/

  • diffcompare two files line by line and show the differences
  • -rrecursively compare any subdirectories found
  • dir1/an argument passed to the command
  • dir2/an argument passed to the command

diff flags & options

-uunified format — the diff style used by patches and git
-rrecursively compare any subdirectories found
-iignore case differences
-wignore all whitespace
-bignore changes in the amount of whitespace
-qreport only whether files differ, not the details
-Ntreat absent files as empty (with -r)
-Coutput the given number of lines of copied context
-Uoutput the given number of lines of unified context

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.