[PLUG] natural join on text files

Colin Kuskie ckuskie at dalsemi.com
Fri Mar 7 15:42:01 UTC 2003


On Fri, Mar 07, 2003 at 03:35:38PM -0800, Russell Senior wrote:
> >>>>> "Russell" == Russell Senior <seniorr at aracnet.com> writes:
> 
> >>>>> "Alice" == Alice Corbin <ali at axian.com> writes:
> 
> Alice> grep -f file1 file2
> 
> Russell> [...] I could send file1 through some "armoring" filter, with
> Russell> a "^" and the front and a delimiter at the end and pipe it
> Russell> like:
> 
> Russell>   $ <filter> file1 | grep -f - file2
> 
> And, here is what seems to be a suitable filter and command-line:
> 
>   $ sed 's/^\(.*\)[ ]*$/^\1($| )/' file1 | egrep -f - file2
> 
> I'll stipulate that I don't care about whitespace at the end of line
> in file1, since it is mostly invisible and caring about it seems more
> likely to cause confusion.  
> 
> In order to match lines that begin with my key and then either end or
> have a delimiter followed by other data, I need (?) an optional, such
> as ($| ) in egrep syntax.
> 
> Comments?

You really think that this is easier than doing it in perl?

Colin




More information about the PLUG mailing list