bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comm: summary patch


From: Andrew Stribblehill
Subject: Re: comm: summary patch
Date: Thu, 14 Jul 2005 00:58:08 +0100
User-agent: Mutt/1.5.6+20040907i

Quoting Bob Proulx <address@hidden> (2005-07-12 20:39:26 BST):
> Paul Eggert wrote:
> > Andrew Stribblehill writes:
> > > It can sometimes be coded with awk, sure:
> > >
> > > #! /bin/sh
> > > # usage: commsum <file(s)>
> > >
> > > awk '
> > > BEGIN {t[0]=0; t[1]=0; t[2]=0}
> > >       {match($0,/^\t*/); t[RLENGTH]++}
> > >   END {printf "%d\t%d\t%d\n",t[0],t[1],t[2]}
> > > ' "$@"
> 
> This is off topic but as a shell script that does nothing but calls
> awk I would make that a pure awk script.  There is no need for the
> shell to be there at all.  '#!/usr/bin/awk' or '#!/usr/bin/env awk' or
> whatever and the appropriate script changes.

Sorry, yes. That was culled from my script that has to work in Linux
and Solaris, so I had to define $AWK on the basis of arch before
invoking it.

> > > However, this presumes that the input has no leading tabs in it.
> > 
> > How about this?
>
>   seq 10 19 > f1
>   seq 16 25 > f2
>   echo $(comm -23 f1 f2 | wc -l) $(comm -13 f1 f2 | wc -l) $(comm -12 f1 f2 | 
> wc -l)
>   6 6 4
> 
> And of course any single value is very simple.
> 
>   comm -23 f1 f2 | wc -l
>   6
> 
> I am skeptical of how much use an option like this would really get.
> And it is pretty straight-forward to code a similar solution
> presently, the only disadvantage being that it is multipass.

I think you've convinced me. I hadn't considered the multipass
approach.

Thanks.
-- 
ROCKALL MALIN
WEST OR SOUTHWEST 4 OR 5, INCREASING 6 OR 7 AT TIMES. OCCASIONAL RAIN
LATER. MODERATE OR GOOD WITH FOG PATCHES




reply via email to

[Prev in Thread] Current Thread [Next in Thread]