Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

sed find/replace a pattern, but not this one..

$
0
0
I've got a file like so:

Code:

...lots of lines, etc.
push "route 10.8.0.0 255.255.255.0"
push "route 192.168.1.123 255.255.255.0"
...lots of lines, etc.

I want to sed find/replace the IP address in the second line, whatever it is, with a new IP address, but I don't want to touch the first line.

So essential I want to find the line like:

Code:

push "route [0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3} 255.255.255.0"
But NOT have it match the push "route 10.8.0.0 255.255.255.0" line

There are lots of lines in the file, so the could be anywhere in it.


Thank you!!!!

Viewing all articles
Browse latest Browse all 16232

Trending Articles