Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to make a tricky substitution with sed:
I have a file 'test.txt' with the following records:
address: 192.168.120.1
other: 192.168.120.15
list: 2here: 192.168.120.1;192.168.120.2
files: list: 2here: //192.168.120.1/filesI would like to change all the 192.168.120.1 occurences with 129.181.231.23
For this, I use the following command:
sed -e 's/192\.186\.120\.1/129\.181\.231\.23/g' test.txt > newtest.txtBut the problem is that the second line is then replaced by this one:
other: 129.181.231.235
No problem, but if I use the following command:
sed -e 's/192\.186\.120\.1[^0-9]/129\.181\.231\.23/g' test.txt > newtest.txtThe ';' disapears in the third line and the '/' disapears too in the last line!
What I would like to do is checking the character that follows a string without replacing or deleting it.I have no more ideas. Is it possible to do such a thing with only one sed command? If not, any ideas?
Thanks !

![]() |
Unowned accounts
|
ksh yyddd (julian date) t...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |