[PLUG] natural join on text files

Russell Senior seniorr at aracnet.com
Mon Mar 10 14:24:02 UTC 2003


>>>>> "Russell" == Russell Senior <seniorr at aracnet.com> writes:

Russell> And, here is what seems to be a suitable filter and
Russell> command-line:

Russell>   $ sed 's/^\(.*\)[ ]*$/^\1($| )/' file1 | egrep -f - file2

Just a followup, my sed command is broken (doesn't strip trailing
white space).  This one seems to work better and is a little more
compact:

  $ sed -e 's/^/^/' -e 's/ *$/($| )/' file1 | egrep -f - file2

The first -e clause is a little confusing at first glance, appearing
to replace a caret with a caret.  However, the caret in the pattern
matches the start of line, while the caret in the replacement is a
literal.  

The second -e clause replaces trailing white space with the optional
pattern for egrep.

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