Sorry, obviously didn't read your question properly.
Correct script is:

users=`cat in.txt | cut -f2 -d'|'|sort -n |uniq`
for i in $users
do
userrecs=`cat in.txt | grep $i`
yesc=`echo $userrecs | grep -o YES|wc -l `
noc=`echo $userrecs | grep -o NO|wc -l `
nac=`echo $userrecs | grep -o NA|wc -l `
echo "$i $yesc $noc $nac"
done

On Sun, Feb 28, 2010 at 12:21 AM, Tony Likhanga <tlikhanga@gmail.com> wrote:
Thanks a bunch Rsohan :) and Micheal.

Michael, the awk script did it in a breeze.
Rsohan, there's some glitch in the bash script. It gives an output in the form:

123456780    0
123456781    1
123456782    1
123456780    1
123456781    0
123456782    1


A quick grep & word count does not yield a count similar to what the other two approaches gave.
Also, the script takes a tad too long to execute :).
I believe some fine tuning should hack it.

Thanks,
Tony.



_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1fbjAwOUE&hl=en
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
Other lists
-------------
Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science:  http://lists.my.co.ke/cgi-bin/mailman/listinfo/science
kazi:     http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general