Last active
October 20, 2016 14:04
-
-
Save hxmuller/660ce0b1757da7d5434e1a058e4e02bd to your computer and use it in GitHub Desktop.
find and remove duplicate files from the second of two directories
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
# modify directory1/ and directory2/ paths as appropriate | |
# | |
# diff - compare files line by line | |
# -s report when two files are the same | |
# -r recursively compare any subdirectories found | |
# sed - stream editor for filtering and transforming text | |
# -n suppress automatic printing of pattern space | |
# cut - remove sections from each line of files | |
# -f select only these fields | |
# -d use DELIM instead of TAB for field delimiter | |
# xargs - build and execute command lines from standard input | |
diff -sr directory1/ directory2/ | sed -n '/identical/p' | cut -f4 -d' ' | xargs rm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment