Cool, how about the shell equivalent:
while read num label; do printf "%s\t%*s\n" "$label" "$num" | tr ' '
You could for e.g. get a barchart representation of filesizes in the
current dir like:
max_val=`find -maxdepth 1 -printf "%s\n" | sort +0n | tail -1`
scale_val=`expr $max_val / 70`
find -maxdepth 1 -type f -printf "%s %p\n" |
while read num label; do snum=`expr $num / $scale_val + 1`; printf
"%s\t%*s\n" "$label" $snum | tr ' ' '*'; done
Fergal Daly wrote:
>I'm sure this exact piece of Perl has been written thousands of times by a
>other people but I wrote it today and I think it's lovely
>>perl -pe 's/.*?(\d+)(.*)/"$2 ".("*" x $1)/ge'
>>will draw a histogram. It takes lines of the form
>>and produces lines of the form
>>where there are 123 *s
>>Got a list of usernames that have logged in over the last week?
>>sort list | uniq -c | perl -pe 's/.*?(\d+)(.*)/"$2 ".("*" x $1)/ge'
>>will graph them.
>>I had a bunch of account numbers generated by some unknown algorithm and I
>wanted to know would it be good idea to to use the last 2 characters as a
>hash. So I grabbed out the last two chars of each one and luckily enough
>>sort last_two | uniq -c | cut -f 1 | sort | uniq -c | perl -pe 's/.*?(\d+)(.*)/"$2 ".("*" x $1)/ge'
>>gave me a nice tight bell curve.
>>I love Perl :-)
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!