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: Tue, 12 Jul 2005 14:59:22 +0100
User-agent: Mutt/1.5.6+20040907i

Quoting Paul Eggert <address@hidden> (2005-07-11 23:10:11 BST):
> Andrew Stribblehill <address@hidden> writes:
> 
> > $ comm -123 /tmp/sorted /tmp/sorted-with-a-line-removed
> > 1   0       45
> 
> Surely you meant "comm -123s"?

Yes I did, sorry.

> The -s option seems of relatively limited use, as it can be programmed
> up with the existing utilities -- perhaps you can show some examples
> of why it's handy to have around?

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]}
' "$@"

However, this presumes that the input has no leading tabs in it. And
there's no way to avoid that, short of preprocessing:

sed 's/^/#/' < f1 > f1.safe
sed 's/^/#/' < f2 > f2.safe
comm f1.safe f2.safe | commsum

When considered in this way, I believe adding three counters to comm
starts to look like the natural solution.

Does anyone else agree with me, or shall I just crawl back under my
rock? ;)

> > any complex legalese, right?
> 
> Most likely we'd need papers once you did all the documentation and so
> forth.  (Usually the documentation is the hard part.  :-)

Heh. Well, that's not a problem for me.

By the way, my patch probably doesn't cleanly apply against CVS head,
but it's a trivial fix to get it to do so.

-- 
BISCAY
NORTHEAST 4 OR 5. FAIR. GOOD




reply via email to

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