|
Home > Archive > Unix Shell > September 2007 > egrep pattern match problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
egrep pattern match problem
|
|
| peter sands 2007-09-17, 7:22 pm |
| Hi,
I am trying to extract codes from a file, that only have 4 numbers
after the 'EDT.'
example file:
EDT.1299
EDT.53992
EDT.34013
EDT.solide
When using the following , it will exclude any non-chars , but returns
all the rest of EDT.* matches ie: any numbers followed after EDT.
When I only want EDT. plus 4 numbers
$ egrep 'EDT.[0-9]{4}' resp.txt
EDT.1299
EDT.53992
EDT.34013
This is running on aix. Any pointers please.
Thanks
Pete
| |
| Cyrus Kriticos 2007-09-17, 7:22 pm |
| peter sands wrote:
>
> I am trying to extract codes from a file, that only have 4 numbers
> after the 'EDT.'
>
> example file:
> EDT.1299
> EDT.53992
> EDT.34013
> EDT.solide
>
>
> When using the following , it will exclude any non-chars , but returns
> all the rest of EDT.* matches ie: any numbers followed after EDT.
> When I only want EDT. plus 4 numbers
>
> $ egrep 'EDT.[0-9]{4}' resp.txt
>
> This is running on aix. Any pointers please.
egrep 'EDT.[0-9]{4}$' resp.txt
--
Best regards | "The only way to really learn scripting is to write
Cyrus | scripts." -- Advanced Bash-Scripting Guide
| |
| peter sands 2007-09-17, 7:22 pm |
|
>
> egrep 'EDT.[0-9]{4}$' resp.txt
>
> --
> Best regards | "The only way to really learn scripting is to write
> Cyrus | scripts." -- Advanced Bash-Scripting Guide
Thanks, that works
Pete
| |
| Stephane CHAZELAS 2007-09-18, 1:27 pm |
| 2007-09-17, 11:32(-07), peter sands:
> I am trying to extract codes from a file, that only have 4 numbers
> after the 'EDT.'
>
> example file:
> EDT.1299
> EDT.53992
> EDT.34013
> EDT.solide
>
>
> When using the following , it will exclude any non-chars , but returns
> all the rest of EDT.* matches ie: any numbers followed after EDT.
> When I only want EDT. plus 4 numbers
>
>
> $ egrep 'EDT.[0-9]{4}' resp.txt
> EDT.1299
> EDT.53992
> EDT.34013
[...]
grep -Ex 'EDT.[0-9]{4}' resp.txt
--
Stéphane
|
|
|
|
|