Comparing two directories

Sometimes it's useful to check whether two directories contain the same files, and whether the files that match are exactly the same.

Assume you have two directories: dir1 and dir2

First, compare the listing of files in the dirs:

find dir1 |sort > contents_dir1.txt
find dir2 |sort > contents_dir2.txt

(I'm sure there are ways to exclude certain patterns, but I can't be bothered because I don't need it at this point.)

Next, compare the two listings using diff ( piping it to colordiff gives pretty colours, using less enables you to actually see what is different if the list is very long).

diff -u contents_dir1.txt contents_dir2.txt |colordiff |less

If you see files here for which you don't care about whether they are identical, remove them.  Sed is your friend if there are many of them.

sed -i '/<pattern>/d' contents_dir1.txt
sed -i '/<pattern>/d' contents_dir2.txt

Now make md5sums of all files listed in contents_dir1.txt and contents_dir2.txt.  Redirecting stderr to /dev/null suppresses "<blabla> is a directory" warnings from the md5sum command

cat contents_dir1.txt |xargs md5sum > md5sums_dir1.txt 2> /dev/null
cat contents_dir2.txt |xargs md5sum > md5sums_dir2.txt 2> /dev/null

And once again, use diff to compare the md5sums.  From here, it's up to you to decide what to do with files that are different :-)

diff -u md5sums_dir1.txt md5sums_dir2.txt |colordiff |less

 Permalink

Matrox Triplehead2Go and linux

I am the happy owner of a Matrox TripleHead2Go and three 19" TFT screens. Needless to say this makes for some pretty cool gaming moments (see the Dead Space gallery for some, much too small, screenshots to get an idea of the view you get).

Installation under Windows was fairly easy with the included software.  Getting the thing to work under Linux was ... also fairly easy.

All that was required was a small edit of xorg.conf :setting the Modes parameter under the Screen section (subsection Display) to "3840x1024" was enough.

The one other thing I did in order to be able to maximize windows to just one screen instead of having them span all three, was add the following line to the Device section : 

Option "TwinViewXineramaInfoOverride"   "1280x1024+1280+0, 1280x1024+0+0, 1280x1024+2560+0"

Notice that I start with the middle screen (+1280+0), then put the left one (+0+0), and then the right one (+2560+0).  This is to ensure that the middle screen is used as the "main" screen (e.g. to decide where to display GDM).

More screenshots and possibly some pictures will follow, eventually.  For now, here's my xorg.conf.

Related Entries:
Importing ical to J-Pilot
 Permalink
1-2/2