Re: [Perl-unix-users] Counting words

2006-04-26 Thread listmail
If it doesn't have to be perl: cat t.txt | awk '{ print $1 }' | sort | uniq -c Sharp, Craig wrote: I have a file that contains many li˜es. Here is an example: evaluate eaprod 7844 2 15688 0 2 evaluate agncyis 7347 2 14694 0 1 agncyis compstr 1117 2 0 0 0 evaluate highcost 7036 4 28144 0 0 eval

RE: [Perl-unix-users] Counting words

2006-04-26 Thread Matt Schneider
Title: Counting words Craig,   A fairly simple way to do this would be to open the file and step though it tracking the first words like this:   open FH, "the_file.txt"; foreach $line () {     # non-greed pattern match to get the first word on the line    ($first_word) = $line  =~ /^(\S+?)\s

Re: [Perl-unix-users] Counting words

2006-04-26 Thread Aleksandar Jelenak
I need to loop through and find the first word in each line and count the number of lines that contain this word in the first position. How about this: $ cat file-with-words | cut -d" " -f1 | sort | uniq -c -Aleksandar ___ Perl-Unix-Users ma

Re: [Perl-unix-users] Counting words

2006-04-26 Thread pDale
On 4/26/06, Sharp, Craig <[EMAIL PROTECTED]> wrote: I have a file that contains many li˜es.  Here is an example: evaluate eaprod  7844   2 15688 0 2 ... opncon   auditrec    8842   1  8842 0 1 I need to loo

Re: [Perl-unix-users] Counting words

2006-04-26 Thread $Bill Luebkert
Sharp, Craig wrote: > I have a file that contains many li˜es. Here is an example: > > evaluate eaprod 7844 2 15688 0 > 2 > evaluate agncyis 7347 2 14694 0 > 1 > agncyis compstr 1117