On Thu, Feb 12, 2009 at 4:50 AM, Drew <[email protected]> wrote: > I haven't seen this for a while, so I'll throw this one out that I had to > use yesterday: > > Now, there's always the outside chance you want to know which servers the > event happened on most. The answer is obvious - pipe it through sort again! > > lauas...@angel(~)$ sort somefile|uniq -c|sort > 2 web1 > 2 web3 > 3 web2 >
corollary: Let's say you have a list that is several gigs long and you want a status bar to show you how long it taking to sort something. Enter pv ( pipe viewer): Generally available on Linux, you may have to apt-get it it. Here is the source if you need it:http://www.ivarch.com/programs/pv.shtml >From the man pages: A simple example to watch how quickly a file is transferred using nc(1): pv file | nc -w 1 somewhere.com 3000 How to adapt to the sort example: pv -cN sort somefile|uniq -c|sort > > So there you are. Obviously this becomes more and more handy as you > progress upwards in the number of lines in somefile (some number of > thousands, I was dealing with!) but I loaded up on the job and took care of > what I was told was an impossible task, and handled it in record time, > thanks to these two commands, which also helped me prove something in > addition to providing some valuable information, something it pays to > remember every day: > > The people who have been designing and using Unix since it's inception are > smart/lazy enough to have wanted to do many of the things we occasionally > run in to that seem like tedious tasks. They have designed the tools to make > doing these things easy. Knowing these tools exist can make your life > easier, and get you to the bar faster. > ditto && true :-) Andrew McElroy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NLUG" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en -~----------~----~----~----~------~----~------~--~---
