Re: [ILUG] shell scripting help required

From: Chris Higgins (chris.higgins at domain horizon.ie)
Date: Wed 01 Aug 2001 - 09:38:43 IST


> On Wed, Aug 01, 2001 at 09:13:38AM +0100, hrishy wrote:
> > Helloi have a text file with the following feilds
> >
> > components not found/ident desc
> > ---------------------------------------------
> > label | not found
> > report | not found
> > label |not found
> > i would like to have a count of all not found
> > by components........

grep "not found" file | wc -l

Or - if you can expect the string 'not found' to appear in
the components column,

cat file | awk -F'|' ' {print $2}' | grep "not found" | wc -l

>
> uh. by any chance can i get part of your grade and/or salary?

Perl programmers... obfuscated to the hilt. :-)
And you had the cheek to put in an message that confuses things
even more

"10 not found"

Does that mean there were ten or not :)

Also - you'll match 'not found' any column
>
> perl -ne 'if (/not found/) {s/^[\w]* |.*/\1/;$s{$1}++} END {foreach $s (sort(keys(%s))) {print "$s{$s} $s not found.\n"}}'
>
> kevin
>
> --
> kevin at domain suberic.net simple four line sigs -
> fork()'ed on 37058400 bandwidth friendly; nice to do.
> meatspace place: work some admins clueless.
> http://suberic.net/~kevin --netiquette haiku 2001
>
> --
> Irish Linux Users' Group: ilug at domain linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at domain linux.ie

-- 
** Chris Higgins                         e: chris.higgins at horizon.ie **
** Technical Business Development        tel: +353-1-6204916            **
** Horizon Technology Group              fax: +353-1-6204949            **


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:11:25 GMT