Re: [PLUG] egrep syntax correction

2015-07-05 Thread Pete Lancashire
AH ! .. that will do it :-) I still keep forgetting there is the posix regexp's On Sun, Jul 5, 2015 at 9:12 AM, Rich Shepard wrote: > On Sun, 5 Jul 2015, Pete Lancashire wrote: > > > Just out of curiosity can I get a copy of the file, and what version of > > grep are you using ? > > Pete, > >

Re: [PLUG] egrep syntax correction

2015-07-05 Thread Rich Shepard
On Sun, 5 Jul 2015, Pete Lancashire wrote: > Just out of curiosity can I get a copy of the file, and what version of > grep are you using ? Pete, My error: I was looking at the wrong portion of the data file; the first character in the data section us U, not P. The uppercase P is how the code

Re: [PLUG] egrep syntax correction

2015-07-05 Thread Pete Lancashire
Rich, Just out of curiosity can I get a copy of the file, and what version of grep are you using ? -pete On Sun, Jul 5, 2015 at 7:35 AM, Rich Shepard wrote: > On Sun, 5 Jul 2015, Rich Shepard wrote: > > > station on the mainstem Humboldt River. The first 212 lines of the 851 > lines > > in the

Re: [PLUG] egrep syntax correction

2015-07-05 Thread Rich Shepard
On Sun, 5 Jul 2015, Rich Shepard wrote: > 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. Mis-remembered: It is the first 612 lines that are comments and the 613th line that contains column headers. Rich __

Re: [PLUG] egrep syntax correction

2015-07-05 Thread Rich Shepard
On Sat, 4 Jul 2015, Galen Seitz wrote: > galens@lion:~$ grep -c '^P' test.txt > 7 > galens@lion:~$ grep -c '^P[0-9]' test.txt > 5 > galens@lion:~$ grep -c '^P[0-9]\{5\}' test.txt > 3 > galens@lion:~$ grep --version > GNU grep 2.6.3 galen, Thank you. I had tried all those flavors and grep -c r

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Galen Seitz
On 07/04/15 17:29, Rich Shepard wrote: > On Sat, 4 Jul 2015, Pete Lancashire wrote: > >> $ cat p | egrep -cE '^P[[:digit:]]{5}' >> 4 > > [rshepard@salmo ~]$ cat p | egrep -cE '^P[[:digit:]]{5}' hrwq.dat > cat: p: No such file or directory > 0 > [rshepard@salmo ~]$ cat hrwq.dat | egrep -cE '^P[[:d

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Rich Shepard
On Sat, 4 Jul 2015, David Fleck wrote: > Try removing the backslashes: > egrep -cE "^P[[:digit:]]{5}" > That works for me. David, That was one of the first flavors I tried; still doesn't work: [rshepard@salmo ~]$ egrep -cE "^P[[:digit:]]{5}" hrwq.dat 0 After a number of futile attempts

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Rich Shepard
On Sat, 4 Jul 2015, Pete Lancashire wrote: > $ cat p | egrep -cE '^P[[:digit:]]{5}' > 4 [rshepard@salmo ~]$ cat p | egrep -cE '^P[[:digit:]]{5}' hrwq.dat cat: p: No such file or directory 0 [rshepard@salmo ~]$ cat hrwq.dat | egrep -cE '^P[[:digit:]]{5}' 0 Still no joy. Let's let it rest. Thanks

Re: [PLUG] egrep syntax correction

2015-07-04 Thread David Fleck
On Sat, 2015-07-04 at 19:28 -0400, Pete Lancashire wrote: > To HOT to think > > don't forget to end the regexp stop with a non-digit if you dont > P12345 will pass. > > On Sat, Jul 4, 2015 at 7:25 PM, Pete Lancashire > wrote: > > > Don't use the back slash, and use single quotes to force all th

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Pete Lancashire
D**M I've got to stop using this F gmail and get back to basics $ cat p | egrep -cE '^P[[:digit:]]{5}' 4 On Sat, Jul 4, 2015 at 7:52 PM, Pete Lancashire wrote: > > $ cat p > P12345 > P123 > P12 > P1 > S1 > S12 > S123 > S1234 > S12345 > P1234 > P123456 > P1234z > P12345a > P12345abc > > $

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Pete Lancashire
$ cat p P12345 P123 P12 P1 S1 S12 S123 S1234 S12345 P1234 P123456 P1234z P12345a P12345abc $ cat p | egrep -ce '^P[[:digit:]]{5}' 4 $ cat p | grep -ce '^P[[:digit:]]{5}' 0 OH OH .. should be (upper case) E :-) $ cat p | grep -ce '^P[[:digit:]]{5}' 0 On Sat, Jul 4, 2015 at 7:43 PM, Rich Shep

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Rich Shepard
On Sat, 4 Jul 2015, Pete Lancashire wrote: > don't forget to end the regexp stop with a non-digit if you dont > P12345 will pass. There is content after the Pn; all I want is a count of the number of lines beginning with Pn. Rich ___ PLUG ma

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Rich Shepard
On Sat, 4 Jul 2015, Pete Lancashire wrote: > Don't use the back slash, and use single quotes to force all the > expression to go to egrep directiy Pete, First I tried without the backslashes but my reading of the man page caused me to try. Didn't work either way. $ grep -ce '^P[[:digit:]]{5}

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Pete Lancashire
To HOT to think don't forget to end the regexp stop with a non-digit if you dont P12345 will pass. On Sat, Jul 4, 2015 at 7:25 PM, Pete Lancashire wrote: > Don't use the back slash, and use single quotes to force all the > expression to go to egrep directiy > > -pete happy HOT 4th > > On Sat, J

Re: [PLUG] egrep syntax correction

2015-07-04 Thread Pete Lancashire
Don't use the back slash, and use single quotes to force all the expression to go to egrep directiy -pete happy HOT 4th On Sat, Jul 4, 2015 at 7:09 PM, Rich Shepard wrote: >I have an 851 line data file in which certain lines begin with P > followed > by 5 digits. I want to count the number

[PLUG] egrep syntax correction

2015-07-04 Thread Rich Shepard
I have an 851 line data file in which certain lines begin with P followed by 5 digits. I want to count the number of those lines. Despite reading the grep man page I am missing the correct syntax. The expression egrep -cE "^P[[:digit:]]\{5\}" hrwq.dat returns a count of zero (0). So