[Fwd: [olug] Unix Tip: AWK THE STATS]

Jay Hannah jay at jays.net
Sat Jun 21 10:15:04 UTC 2003


Ouch. 15 lines of awk? How about:

   cut -d: -f 7 /etc/passwd | sort | uniq -c

instead? You know something is simple when even I don't recommend a
little Perl script. -grin-

Jay Hannah
Omaha Perl Mongers: http://omaha.pm.org




-------- Original Message --------
Subject: [olug] Unix Tip: AWK THE STATS
Date: Thu, 19 Jun 2003 08:52:03 -0700
From: Unix Guru Universe <listserv at ugu.com>
Reply-To: Omaha Linux User Group <olug at olug.org>
To: olug at olug.org



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

			      UNIX GURU UNIVERSE 
			         UNIX HOT TIP

			Unix Tip 1996 - June 19, 2003

		    http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


AWK THE STATS


AWK script for getting 
statistics.

The script gives the 
statistics of the default 
shell set for the users.

i.e. Number of users using 
csh,ksh or sh

$cat stat_demo.awk
#start here
BEGIN{
FS=":"
#seperator is set to :
}
{
#$7, is 7 field in passwd file
  stat_array[$7]=stat_array[$7]+1;
}
END{
print "Login-Shell Count" ;
for (i in stat_array) print i, stat_array[i]
#Displays statistics
}       
#end here


To use this , Just say

awk -f stat_demo.awk /etc/passwd

or

cat /etc/passwd | awk stat_demo.awk

This tip generously supported by: dkotian1 at rediffmail.com


--------------------------------------------------------------------------
To Subscribe:    http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe:  http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND
ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX 
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU  ADVISES THAT 
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips at ugu.com - Copyright 1994-2001
==========================================================================

_______________________________________________
OLUG mailing list
OLUG at olug.org
http://lists.olug.org/mailman/listinfo/olug


More information about the OLUG mailing list