nv-l
[Top] [All Lists]

AW: Counting lines in a file containing

To: nv-l@lists.tivoli.com
Subject: AW: Counting lines in a file containing
From: Schiffinger Ralph 2100 <Ralph.Schiffinger@ERSTEBANK.AT>
Date: Thu, 18 Feb 1999 17:19:00 +0100
Reply-to: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
Sender: Discussion of IBM NetView and POLYCENTER Manager on NetView <NV-L@UCSBVM.UCSB.EDU>
i'll try a commandline-freehander without net...

for lumpi in `sort -u -k2,2 file|awk '{print $2}'`
do
echo "$lumpi occurs `grep $lumpi file|wc -l` times"
done

Let me know if it works...
Regards, Ralph.

 -----Ursprüngliche Nachricht-----
Von:    Steven Thornhill [SMTP:Steven.Thornhill@SOUTHERNELECTRIC.CO.UK]
Gesendet am:    Donnerstag, 18. Februar 1999 16:52
An:     NV-L@UCSBVM.ucsb.edu; Schiffinger Ralph 2100
Betreff:        Re: Counting lines in a file containing exact fields


     You can create an array by awking the second field and sorting
     (unique), then use this array with a loop to count the number of lines
     that match each element of the array. If you need an outline of a
     script let me know.

     Steve


______________________________ Reply Separator 
_________________________________
Subject: Counting lines in a file containing exact fields
Author:  Lucy Premus <lpremus@METLIFE.COM> at SEInternet
Date:    18/02/99 10:06


Is there a korn shell function to count lines in a file that have one field
thats the same.  For example, if my file looks as follows:

server1   NYHO
server2   NYHO
server3   NYHO
server4   RISC
server5   RISC
server6  NYMLB
server7  NYMLB
server8  NYMLB
server9  NYMLB

I want the script to read the file and count up that there are 3 NYHO, 2 
RISC,
and 4 NYMLB.  However theres a catch, in reality my files will be much larger
than this containing much more than 3 different instances.  I don't want to 
have
to compare each line to the literal (ie. NYHO, RISC or NYMLB) because theres
just too many of them.  Is there any easier way?

<Prev in Thread] Current Thread [Next in Thread>
  • AW: Counting lines in a file containing, Schiffinger Ralph 2100 <=

Archive operated by Skills 1st Ltd

See also: The NetView Web