[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Adding to textutils/coreutils
From: |
Stefan Klinger |
Subject: |
Adding to textutils/coreutils |
Date: |
Tue, 29 Mar 2005 12:10:33 +0200 |
User-agent: |
Mutt/1.3.28i |
Hi there!
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).
'dlc Distinct Line Count' counts the number of occurrences of each distinct
line of input. Some examples are given below.
Is it possible to add this tool to the original GNU coreutils package?
Available C source code is
http://www.stefan-klinger.de/files/dlc.tar.bz2
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.
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.
3. Fast Counting of Unique Lines
address@hidden:~> cat foo | dlc | wc -l
172
address@hidden:~> cat foo | sort | uniq | wc -l
172
are equivalent, but the dlc variant is much faster.
Interested? Available C source code is
http://www.stefan-klinger.de/files/dlc.tar.bz2
Questions or suggestion? Please send me an email ;)
Regards,
Stefan
--
Stefan Klinger o/klettern
/\/ bis zum
send plaintext only - max size 32kB - no spam \ Abfallen
http://www.stefan-klinger.de/policy.html
- Adding to textutils/coreutils,
Stefan Klinger <=