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

David L. Willson DLWillson at TheGeek.NU
Wed Sep 3 15:10:22 MDT 2008


$ 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
------------------------------
Mike: Does escaping the open and closed parenths help?
------------------------------
Surprise to me, yes, it does.  I don't get the error any more.  But I also don't get
just the IP address, I get the whole line...  <mumble>

What I'm trying to do is to grep a trashy list of names, nicknames, aliases, and IP
addresses for (something), and in the case of a unique hit, return the IP address only,
and an error of either "not found" or "not found uniquely" in the appropriate other cases.

The first step, where I currently am stuck, is how to return only the IP address, rather
than the whole line.  The rest should be a doddle. (remember Lemmings?)

I'll keep trying and let you know if I figure it out.


More information about the clue-tech mailing list