Grep regex

Hi everyone,

I'm looking for a grep command to match the following pattern from a file:

<EGS>10234567<EGS>

I used this following command to do this:

grep -E '^<EGS>[0-9]{8}<EGS>' test.txt

In output I got:

<EGS>10234567<EGS>

Till now it work, but if I add something at the end of the line for example:

<EGS>10234567<EGS>blabla

In output I got:

<EGS>10234567<EGS>blabla

It works, but I want to only get this in output:

<EGS>10234567<EGS>

Thanks in advance :b:

grep -o -E or grep -oE

1 Like

Thanks It work:):b: