[PLUG] egrep syntax correction

Rich Shepard rshepard at appl-ecosys.com
Sun Jul 5 12:50:06 UTC 2015


On Sat, 4 Jul 2015, Galen Seitz wrote:

> galens at lion:~$ grep -c '^P' test.txt
> 7
> galens at lion:~$ grep -c '^P[0-9]' test.txt
> 5
> galens at lion:~$ grep -c '^P[0-9]\{5\}' test.txt
> 3
> galens at lion:~$ grep --version
> GNU grep 2.6.3

galen,

   Thank you. I had tried all those flavors and grep -c returned 0 in all
cases. Must be something funky with this file.

grep --version
grep (GNU grep) 2.14

   The file contains water quality data from 1929 to a week ago from a
station on the mainstem Humboldt River. The first 212 lines of the 851 lines
in the file are comments; the 213th line is the header. Data chunks are tab
delimited. File size is 222K. Of the data lines, half begin with Rnnnnn
which is a comment for the subsequent parameter line, begining with Pnnnnn.
If anyone wants to play with counting the number of lines of parameter names
and measured concentrations by sampling date using grep -c I'll send you a
copy. I expected that the -c option to grep with an appropriate regex that
indicates 'begining of line has P followed by 5 digits' would work. It does
on test files, but not this database extraction via the USGS WRD Web site.

Thanks,

Rich



More information about the PLUG mailing list