[PLUG] egrep syntax correction

Galen Seitz galens at seitzassoc.com
Sun Jul 5 00:52:50 UTC 2015


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 at salmo ~]$ cat p | egrep -cE '^P[[:digit:]]{5}' hrwq.dat
> cat: p: No such file or directory
> 0
> [rshepard at salmo ~]$ cat hrwq.dat | egrep -cE '^P[[:digit:]]{5}'
> 0
> 
> Still no joy. Let's let it rest.


galens at lion:~$ cat test.txt
foo
P12345
P1234a
P1234
bar
Pbaz
P
P567890hello
P56789world

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
-- 
Galen Seitz
galens at seitzassoc.com



More information about the PLUG mailing list