[Tfug] Got a text formatting/database question ("bash" it to hell?)

Choprboy choprboy at dakotacom.net
Tue Apr 14 19:10:31 MST 2009


On Tuesday 14 April 2009 18:53, Ryan Cresawn wrote:
> Jim,
>
> grep -v 170 file.dat | wc -l

Bzzztt... sorry, but good start. That would exclude (rather in include) 
everything with a "170" appearing in any column, including subsets of 
numbers. I.e., all the following match your filter:
235,170,Early Ballot
170,23,
21703,51,Early Ballot

You could get a bit more specific by first sorting out only the second column, 
but you still need to regex it to properly filter just "170" inclusive:

cat file.dat |awk -F "," "{print $2}' |grep -e '^170$' |wc -l


Adrian




More information about the tfug mailing list