Frequently Asked Questions

« Previous
How do I set up eduPrint for a Linux server?
Next «
Troubleshooting mail - what can I do and whom do I ask?

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

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 <(find directory1 -mindepth 1 | sort) <(find directory2 -mindepth 1 | sort)

This displays files and directories that are unique for directory1.

comm -23 <(find directory1 -mindepth 1 | sort) <(find directory2 -mindepth 1 | sort)

This displays files and directories that are unique for directory2.

comm -13 <(find directory1 -mindepth 1 | sort) <(find directory2 -mindepth 1 | sort)

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

This documentation is covered by GNU Free Documentation License.