|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Sed expression to look up and replace a string with speical condition
Hi,
I have the following xml string and using sed I need to replace the second myConnection's port value to something else. Ofcourse, I do not know that it is always 443.. <myConnection port="80"/> <myConnection port="443"/> <myConnection port="83"/> <myConnection port="82"/> The red marked string has to be replaced with new string. TIA, Sachin |
|
#2
|
||||
|
||||
|
Try this:
Code:
sed -e '2s/\"[0-9]*\"/\"xxx\"/' file.txt The important bit is the 2 just before the substitute command. Just replace xxx with the port it needs to be changed to. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Sed expression to look up and replace a string with speical condition |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|