On Monday 30 Jun 2003 6:52 pm, Ronald J. Hall wrote: > On Monday 30 June 2003 01:04 pm, Todd Slater wrote: > > Yes, it depends on what the text file looks like; in general, > > you're going to probably use sort and then pipe it through uniq, > > such as > > > > cat file.txt|sort|uniq -c > > > > You might need to play some other tricks depending on the way the > > numbers appear in your text file. > > Well, all the numbers from each are in a line, separated by a space, > so its reporting each line of numbers as occuring once. :-)
try tr ' ' '\n' < powerball.txt | sort | uniq -c | sort -r There's a space between the first pair of quotes. cat powerball.txt Here's the numbers I tested it with 11 12 13 14 16 12 13 14 15 16 13 14 15 16 17 14 15 16 17 18 15 16 17 18 19 tr ' ' '\n' < powerball.txt translates all spaces to newlines characters, so each ball is on a line of its own. 11 12 13 14 16 12 13 14 15 16 13 14 15 16 17 14 15 16 17 18 15 16 17 18 19 sort sorts the list of balls so all balls with the same number are adjacent. 11 12 12 13 13 13 14 14 14 14 15 15 15 15 16 16 16 16 16 17 17 17 18 18 19 uniq -c replaces each sequence of identical numbers with a count of the number of times the ball occurs. The first number is the frequency, the second is the ball number: 1 11 2 12 3 13 4 14 4 15 5 16 3 17 2 18 1 19 sort -r sorts the list of frequencies into reverse order, so the biggest number is at the top 5 16 4 15 4 14 3 17 3 13 2 18 2 12 1 19 1 11 -- Richard Urwin
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com