Last active
December 24, 2015 23:49
-
-
Save alancoleman/6883472 to your computer and use it in GitHub Desktop.
diff commands for shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The difference between two folders | |
diff folder_1 folder_2 | |
# The difference between two files | |
diff file_1.txt file_2.txt | |
# The difference between two folders recursive | |
diff -r folder_1 folder_2 | |
# Create a patch file from a diff | |
diff file_1.txt file_2.txt > example.patch | |
# Create a patch file from a diff in unified format ( Denotes what file to be patched in a header) | |
diff -u file_1.txt file_2.txt > example.patch | |
# Patch a file | |
patch file_1.txt < example.patch | |
# Patch a file form a patch in unified format | |
patch < example.patch | |
# Remove a patch | |
patch file_1.txt -R < example.patch | |
# Flags | |
# Recursive, compares every corresponding pair of files in the directory trees, as many levels deep as they go | |
diff --recursive folder_1 folder_2 | |
# or | |
diff -r folder_1 folder_2 | |
# Report identical files | |
diff --report-identical-files folder_1 folder_2 | |
# or | |
diff -s folder_1 folder_2 | |
# Exclude. This option ignores any files or subdirectories whose base names match the shell pattern | |
diff --exclude=pattern folder_1 folder_2 | |
# or | |
diff -x pattern folder_1 folder_2 | |
# http://www.gnu.org/software/diffutils/manual/html_node/index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment