bug-coreutils
[Top][All Lists]
Advanced

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

Re: Adding to textutils/coreutils


From: Bob Proulx
Subject: Re: Adding to textutils/coreutils
Date: Tue, 29 Mar 2005 10:37:33 -0700
User-agent: Mutt/1.5.6+20040907i

Stefan Klinger wrote:
> I've just written a tiny programme that is hardly worth a own
> package. However, I think it could be part of the textutils package
> (now coreutils).

I think that it is great that you would like to share your program.
However for a package such as coreutils that is a core utility package
such additions need to be made very carefully.

> Examples:
> 
> 1. Basic Operation:
> 
>   address@hidden:~> dlc
>   foo
>   bar
>   foo
>   foo
>   bar
>   qux
>   ^D
>          1 qux
>          3 foo
>          2 bar
> 
> Because the line 'foo' appeared three times, 'bar' twice and 'qux' once.

Unfortunately I think you have recreated the 'uniq -c' functionality.

Try this using 'uniq -c'.

  sort /tmp/testfile | uniq -c
        2 bar
        3 foo
        1 qux

> 2. Practical Example
> 
>   address@hidden:/home/sk# grep "\[[[:digit:]]*\]:" /var/log/messages \
>   > | sed 's/[^[]* \([^ ]*\)\[.*/\1/g' \
>   > | dlc \
>   > | sort -r -n -k 1,1;
>       2895 chat
>       1765 pppd
>          5 diald
>          1 lpd
>     
> Reports which programmes created how many entries in /var/log/messages.

On my system (with /var/log/syslog):

  grep "\[[[:digit:]]*\]:" /var/log/syslog \
  | sed 's/[^[]* \([^ ]*\)\[.*/\1/g' \
  | sort \
  | uniq -c 
     54 /USR/SBIN/CRON
    383 postfix/cleanup
    291 postfix/local
      5 postfix/pickup
    586 postfix/qmgr
     11 postfix/smtp
    864 postfix/smtpd
      2 smartd

Thank you very much for the very nice examples.  They illustrated the
use very well.

Bob




reply via email to

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