[PLUG] natural join on text files

Russell Senior seniorr at aracnet.com
Fri Mar 7 14:39:01 UTC 2003


Oops, that should be:

$ cat > file2 <<EOF
1 1 1 57.6
1 2 1 32.1
1 2 3 42
4 5 4 12.3
4 5 6 42
6 3 1 27.6
7 8 9 42
10 6 2 12
EOF

Here's what I've come up with:

  $ awk '{ printf("$1 == %d && $2 == %d && $3 == %d { print $0 }\n",$1,$2,$3) }' file1 | awk -f - file2 

I need this kind of thing *all-the-/sbin/fsck-ing-time*, you'd think I
would have generalized this as a utility by now.

-- 
Russell Senior         ``I've seen every kind of critter God ever made,
seniorr at aracnet.com      and I ain't never seen a meaner, lower, more
                         stinkin' yellow hypocrite than you!'' 
                                        -- Burl Ives as Rufus Hennessy




More information about the PLUG mailing list