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

Choprboy choprboy at dakotacom.net
Tue Apr 14 18:50:26 MST 2009


On Tuesday 14 April 2009 18:34, Jim March wrote:
> Guys,
>
> I have an interesting database problem that I think can be solved on
> the command line in one shot.  But I don't know how :(.
[snip]
> So what I want to do is, strip out every line that does NOT have a
> "170" in the second column, and then produce a line count.  I need to
> know (like ASAP) how many people voted in election 170

Example data election_counts.csv:
235,96,Early Ballot
235,125,
235,126,Early Ballot
235,143,
235,147,Early Ballot
235,148,Early Ballot
235,170,Early Ballot
240,96,Early Ballot
240,125,
240,126,Early Ballot
240,143,
240,147,Early Ballot
240,148,Early Ballot
255,96,Early Ballot
255,125,
255,126,Early Ballot
255,143,
255,147,Early Ballot
255,170,

[ajensen at vagabond ~]$ cat testfile |grep -e '.*,170,*' |wc -l
2

correct answer == 2


Adrian





More information about the tfug mailing list