teh bigbro blog(tm)
Bigbro's foray into the scary world of blogging

Fri, 16 Jun 2006

Unix Tidbits...

From the ILUG mailing list, Padraig Brady had the following useful tips (repeated here so that I can find them and maybe not forget them):

Following on from my previous mail
about finding cruft on a debian system with:
(cat /var/lib/dpkg/info*.list ; find / -type f ) | LANG=C sort | uniq -u

I find set operations like that quite common on the command line:

For unsorted files:

LANG=C sort file1 file2 | uniq              #Union
LANG=C sort file1 file2 | uniq -d           #Intersection
LANG=C sort file1 file1 file2 | uniq -u     #Difference
LANG=C sort file1 file2 | uniq -u           #Symmetric Difference

For sorted files:

LANG=C comm file1 file2 | sed 's/^\t*//'    #Union
LANG=C comm -12 file1 file2                 #Intersection
LANG=C comm -13 file1 file2                 #Difference
LANG=C comm -3 file1 file2 | sed 's/^\t*//' #Symmetric Difference

Note the LANG=C for speed as we're not interested
in the actual order of the items.

Padraig.

posted at: 09:00 | path: /technical | permanent link to this entry


copyright © 2005-2008, Gareth Eason