[PLUG] natural join on text files

Russell Senior seniorr at aracnet.com
Fri Mar 7 14:56:02 UTC 2003


>>>>> "Alice" == Alice Corbin <ali at axian.com> writes:

Alice> grep -f file1 file2

Interesting, but not robust enough.  What happens if the key in file1
doesn't appear at the beginning of the line in file2?  E.g.:

7 1 2 3

in file2 would match the grep pattern "1 2 3" from file1, as would:

11 2 3 43

I could send file1 through some "armoring" filter, with a "^" and the
front and a delimiter at the end and pipe it like:

  $ <filter> file1 | grep -f - file2


-- 
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