Frequently Asked Questions

« Previous
How do I order a personal storage at Argos?
Next »
What is the BMC-IT computer platform and how does it work?

windows ubuntu macos xibo network zenworks android storage


9. How do I compare the content of two directories?

See also: How do I find specific files like the last updated, the one with the longest file name, or the largest one?

The build in tools diff, comm, find and sort in macOS and Linux can be used to compare two directories to see if anything is changed.

Let us assume the files are in the directories called directory1 and directory2.

Finding difference in content

For large datasets this will take some time because the content of all files will be read and compared.

diff -r directory1 directory2

Finding missing or added files

This will be faster because only the list of files and directories in the two directories are compared. The content is not compared. All file names that do not exist in both are printed.

comm -3 <(cd directory1 ; find | sort) <(cd directory2 ; find | sort)

This displays files and directories that are unique for directory1.

comm -23 <(cd directory1 ; find | sort) <(cd directory2 ; find | sort)

This displays files and directories that are unique for directory2.

comm -13 <(cd directory1 ; find | sort) <(cd directory2 ; find | sort)



 

This entry compare.directories was last modified 2020-04-06

   

This documentation is covered by GNU Free Documentation License. 14 ms