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

Ryan Cresawn jrcresawn at gmail.com
Tue Apr 14 20:46:36 MST 2009


On Tue, Apr 14, 2009 at 7:10 PM, Choprboy <choprboy at dakotacom.net> wrote:

> 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


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

Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tfug.org/pipermail/tfug_tfug.org/attachments/20090414/b9fd48b3/attachment-0002.html>


More information about the tfug mailing list