 | Epic shell hack by the inventor of pipesThis is an old story, but it's new to me:
»www.leancrew.com/all-this/2011/1···less-egg
It took me a long time to understand all of it, even though it's a really short script:
tr -cs A-Za-z '\n' |
tr A-Z a-z |
sort |
uniq -c |
sort -rn |
sed ${1}q
The line that gave me the most trouble was "sed ${1}q". The key thing there is that "${1}" is not a sed expression. The shell will expand that with the value of the first command-line parameter to the script. In order to get it to work, I had to paste the lines into a script file and invoke it like this:
cat distribKeys.pl | ./countWords.sh 3
30 ssh
16 print
13 cmd
I had never heard of Doug McIlroy before. I felt like a poser after reading about him. I almost went home.
-- "Be safe be suspicious" |
 pabloMVM join:2003-06-23 kudos:1 | Given he's a mathematician, it's something I'd expect. Very elegant.
Excellent find. He's news to me .. clearly I've been living in a cave.
Cheers, -pablo -- openSUSE 12.2/KDE 4.x ISP: TekSavvy Bonded DSL; backhauled via a 6KM wireless link Assorted goodies: »pablo.blog.blueoakdb.com |