Difference between folders
Solution 1
To compare 2 files, we use the diff command. How do we compare 2 directories? Specifically, we want to know what files/subdirectories are common, what are only in 1 directory but not the other use
diff dir1 dir2
if you are not interested in file differences use
diff -q dir1 dir2 |sort
diff orders its output alphabetically by file/subdirectory name. I prefer to group them by whether they are common, and whether they only exist in the first or second directory. That is why I piped the output of diff through sort in the above command.
Note that by default diff does not reach into the subdirectories to compare the files and subdirectories at that level. To change its behavior to recursively go down subdirectories, add -r.
diff -qr dir1 dir2 |sort
I hope this helps.
Solution 2
diff -Nur directory1 directory2
Solution 3
My favourite for a quick glance:
diff -Ewburq folder1/ folder2/
List filenames (ignoring all kinds of whitespace changes).
To see the whole diff in a nice viewer (removing the -q
option)
diff -Ewbur folder1/ folder2/ | kompare -o -
You could probably find other (better?) diff tools (meld, k3diff etc.?)
If you want, you can include files 'new' to the set with -N
Solution 4
Simply you can do:
git diff --no-index FOLDER1 FOLDER2
Related videos on Youtube
Comments
-
Laser over 1 year
How can I compare recursively 2 folders with same structure.
With usingdiff
orgit diff
frombash
command line? -
MoonKnight over 11 years+1 I like this... But I love your avatar!
-
sehe over 11 years@Killercam Cheers. Visit the Lounge<C++> one day if you like a party of animals :)