[Tutor] counting problem

Alan G alan.gauld at freenet.co.uk
Mon Aug 1 23:17:21 CEST 2005


> What I want to do is quickly count the number of lines that share a 
> value in the 4th column and 5th (i.e. in this line I would count all 
> the line that have '9' and 'ZZZ'). Anyone got any ideas for the 
> quickest way to do this? The solution I have is really ugly. thanks,

Pesonally I'd just use awk:

$ awk '$4==9 && $5=="ZZZ" {count++} END {printf count}' myfile.dat

Should do it.

Alan G. 



More information about the Tutor mailing list