[clue-tech] regex smarties - what am I doing wrong?

David L. Willson DLWillson at TheGeek.NU
Wed Sep 3 10:16:56 MDT 2008


I'm trying to capture and return only the IP address from a line of text.  I can match
it, but something's wrong with the way I'm trying to capture it.  Any thoughts?

dlwillson at aurora:~
$ grep newwave hosts | grep -E --color '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'
69.88.86.210 newwaveenviro

^ That line does successfully color the IP address.

dlwillson at aurora:~
$ grep newwave hosts | sed -e 's/(([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3})/\1/p'
sed: -e expression #1, char 48: invalid reference \1 on `s' command's RHS
dlwillson at aurora:~
$ grep newwave hosts | sed -e 's/(([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3})/\0/p'
69.88.86.210 newwaveenviro
dlwillson at aurora:~
$ grep newwave hosts | sed -e 's/(([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3})/\1/p'
sed: -e expression #1, char 48: invalid reference \1 on `s' command's RHS
dlwillson at aurora:~

Huh...

-- David



More information about the clue-tech mailing list