tldr/pages/common/diff.md

33 lines
1.0 KiB
Markdown
Raw Normal View History

2014-02-02 12:26:10 +00:00
# diff
> Compare files and directories.
> More information: <https://man7.org/linux/man-pages/man1/diff.1.html>.
2014-02-02 12:26:10 +00:00
- Compare files (lists changes to turn `old_file` into `new_file`):
2014-02-02 12:26:10 +00:00
`diff {{old_file}} {{new_file}}`
2014-02-02 12:26:10 +00:00
- Compare files, ignoring white spaces:
2014-02-02 12:26:10 +00:00
`diff --ignore-all-space {{old_file}} {{new_file}}`
2014-02-02 12:26:10 +00:00
- Compare files, showing the differences side by side:
2014-02-02 12:26:10 +00:00
`diff --side-by-side {{old_file}} {{new_file}}`
2014-02-02 12:26:10 +00:00
- Compare files, showing the differences in unified format (as used by `git diff`):
`diff --unified {{old_file}} {{new_file}}`
- Compare directories recursively (shows names for differing files/directories as well as changes made to files):
2014-02-02 12:26:10 +00:00
`diff --recursive {{old_directory}} {{new_directory}}`
2014-02-02 12:26:10 +00:00
- Compare directories, only showing the names of files that differ:
2014-02-02 12:26:10 +00:00
`diff --recursive --brief {{old_directory}} {{new_directory}}`
- Create a patch file for Git from the differences of two text files, treating nonexistent files as empty:
`diff --text --unified --new-file {{old_file}} {{new_file}} > {{diff.patch}}`