Archives

You are currently viewing archive for February 2009

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 '//d' contents_dir1.txt
sed -i '//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 " 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

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.

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:

# $XdotOrg$
#
# Copyright (c) 1994-1998 by The XFree86 Project, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Except as contained in this notice, the name of the XFree86 Project shall
# not be used in advertising or otherwise to promote the sale, use or other
# dealings in this Software without prior written authorization from the
# XFree86 Project.
#
# $XConsortium: XF86Conf.cpp /main/22 1996/10/23 11:43:51 kaleb $

# The ordering of sections is not important in version 4.0 and later.

Section "Module"

Load "dbe"
Load "freetype"
Load "glx"

SubSection "extmod"
Option "omit xfree86-dga"
EndSubSection

EndSection

Section "Files"

FontPath "/usr/share/fonts/misc"
FontPath "/usr/share/fonts/Type1"
FontPath "/usr/share/fonts/100dpi"
FontPath "/usr/share/fonts/75dpi"

EndSection

Section "InputDevice"

Identifier "diNovo Keyboard"
Driver "kbd"
Option "AutoRepeat" "500 30"
Option "XkbRules" "xorg"
Option "XkbModel" "pc104"
Option "XkbLayout" "be"

EndSection

Section "InputDevice"

Identifier "diNovo Mouse"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"

EndSection

Section "Monitor"

Identifier "Acer V193"
HorizSync 30-80
VertRefresh 55-75
DisplaySize 1016 270

EndSection

Section "Device"

Identifier "Geforce GTX260"
VendorName "nVidia"
Option "RenderAccel" "true"
Option "AllowGLXWithComposite" "true"
# Fake Xinerama to be able to maximize to one display on the TH2Go
Option "TwinViewXineramaInfoOverride" "1280x1024+1280+0, 1280x1024+0+0, 1280x1024+2560+0"
Driver "nvidia"

EndSection

Section "Screen"

Identifier "Screen1"
Device "Geforce GTX260"
Monitor "Acer V193"
DefaultDepth 24

Subsection "Display"
Depth 8
Modes "3840x1024'
ViewPort 0 0
EndSubsection

Subsection "Display"
Depth 16
Modes "3840x1024"
ViewPort 0 0
EndSubsection

Subsection "Display"
Depth 24
Modes "3840x1024"
ViewPort 0 0
EndSubsection

EndSection

Section "ServerLayout"

Identifier "Simple Layout"
#Screen "Screen1"
Screen 0 "Screen1" 0 0
InputDevice "diNovo Mouse" "CorePointer"
InputDevice "diNovo Keyboard" "CoreKeyboard"
Option "AIGLX" "true"
Option "BlankTime" "5" # Blank screen after 5 minutes
Option "StandbyTime" "10" # Turn off screen after 10 minutes

EndSection

Section "Extensions"

Option "Composite" "Enable"

EndSection