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

Choprboy choprboy at dakotacom.net
Tue Apr 14 22:21:13 MST 2009


On Tuesday 14 April 2009 20:46, Ryan Cresawn wrote:
[snip]
> > cat file.dat |awk -F "," "{print $2}' |grep -e '^170$' |wc -l
[snip]
> Good observation Adrian about the column sensitivity.  I overlooked that
> and was confused about what Jim sought.  Could it be simpler than this?
>
> grep -c ",170," file.dat
>

It could, depends on exactly what the data looked like. If it is strictly in 
the format "<x>,<y>,<z>" then grep ",<y>," file.dat would work perfectly. Ive 
had the unfortunate experience of having to do this thing, in datasets of 
100s of thousands of lines, multiple columns wide... It always seems that 
somewhere, somehow, someone manages to slip in some characters you didn;t 
initially expect. :)

Adrian




More information about the tfug mailing list