nv-l

Re: Counting lines in a file containing exact fields

1999-02-18 11:18:16
Subject: Re: Counting lines in a file containing exact fields
From: "Owens, Blaine C" <bowens AT EASTMAN DOT COM>
To: nv-l AT lists.tivoli DOT com
Date: Thu, 18 Feb 1999 11:18:16 -0500
awk '{print $2}' filename | sort | uniq -c

Blaine Owens
Eastman Chemical Company
Email - bowens AT eastman DOT com
Phone - (423)229-3579
Fax     - (423)229-1188

> -----Original Message-----
> From: Lucy Premus [SMTP:lpremus AT metlife DOT com]
> Sent: Thursday, February 18, 1999 10:06 AM
> To:   NV-L AT UCSBVM.ucsb DOT edu
> Subject:      Counting lines in a file containing exact fields
>
> 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?