diff
FilesFundamentals In simulator In real LinuxCompare files line by line
Name: diff = difference
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
diff compares two files line by line and prints the changes needed to turn the first into the second. The unified format (-u) is the most readable and is what patches and git diff use.
Exit status: 0 same, 1 different, 2 trouble, so scripts can use it to test whether files match.
Syntax
diff [OPTION]... FILE1 FILE2Common options
| -u / --unified | Unified format, as used by patches |
| -y / --side-by-side | Show the two files side by side |
| -r / --recursive | Compare directories recursively |
| -N / --new-file | With -r: treat a file missing on one side as empty |
| -q / --brief | Only report whether files differ |
| -i / --ignore-case | Ignore case |
| -w / --ignore-all-space | Ignore all white space |
| -b / --ignore-space-change | Ignore changes in the amount of white space |
| -B / --ignore-blank-lines | Ignore changes that are only blank lines |
| -x / --exclude PATTERN | With -r: skip files matching PATTERN |
| --color | Colour added and removed lines |