[Gllug] simple file matching

Nix nix at esperi.org.uk
Wed Aug 24 21:57:46 UTC 2005


On Wed, 24 Aug 2005, Tethys whispered secretively:
> If the lists are unordered, then fix that first, so the standard tools
> work:
> 
> sort -u file1 > file1.sorted
> sort -u file2 > file2.sorted
> comm -12 file1.sorted file2.sorted

Or, with any halfway competent POSIX shells:

comm -12 <(sort -u file1) <(sort -u file2)

which is clearer, faster, and doesn't require messing with temporary
files (which should always go in a securely-created subdir, in any
case).


(today, for my sins, I used a mess of sed and awk to translate some
stereotyped PL/SQL to C. Then I came to my senses and realised what I'd
done: I'm wondering if there is any cure for this obvious insanity. I
call this disorder `CWeb syndrome', after the `convert' script therein,
which sort of kind of turns Pascal into C if viewed in bad light.)

-- 
`... published last year in a limited edition... In one of the
 great tragedies of publishing, it was not a limited enough edition
 and so I have read it.' --- James Nicoll
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list