I use grep and egrep countless times daily but once in awhile I come up with a problem that grep can do part of and egrep can do the other part but neither can do both.
Maybe I just need the syntax?
I have a file with 3 digit codes something like this:
001003009000000000
002004008997999000
... etc etc
I want to find lines with the same code repeated so:
grep '00\([0-9]\).*00\1'
will find it but not necessarily in the correct format. E.g. it will incorrectly identify '001030010' even though the codes are 1, 30 and 10.
I would like to use: grep '00\([0-9]\)\(...\)*00\1'
but the wildcard does not apply to groups in grep. And egrep cannot backreference a match in the form \n.
How can it be done?
2007-02-22
07:43:26
·
1 answers
·
asked by
scruffy
5
in
Computers & Internet
➔ Programming & Design
I've read the manuals. They seem to indicate that it can't be done. I'd like to know if there is another way.
2007-02-22
08:27:58 ·
update #1