Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed script 1

Status
Not open for further replies.

stu78

Programmer
May 29, 2002
121
GB
Hi,

I am trying to replace the line;

Tcp Port= 0xad33; REG_DWORD

with

Tcp Port= 1xad11; REG_DWORD

In a registry file, however it is not working.
Any Ideas?

Stu
 
Thanks,

Problem is that this line is unique, where as the registry values are not, the only way I can do this is by substituting the full line...

My sed skills are not too good, but I think there must be a problem with the spaces?


Stu
 
And this ?
sed '/^Tcp Port=/s/0xad33;/1xad11;/'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PH,

Great solution, works perfect.

Stu
 
Hi,

How could I modify this to find & substitute the nth expression of the same line?

Preferably using SED?

DC
 
For the 3rd expression:
sed '/^Tcp Port=/s/0xad33;/1xad11;/3'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

I have tried this way before - but it does not seem to work - it does not even seem to replace.

Any ideas why?

 
Here is a sample of the file I need to change;

Tcp Idle= 0xa; REG_DWORD
Thread Pool= 0x6; REG_DWORD
Tcp Idle= 0xa; REG_DWORD
Thread Pool= 0x8; REG_DWORD
Files= 0xa; REG_DWORD
Tcp Port= 0xad33; REG_DWORD
Cache= 0x1; REG_DWORD
Tcp Port= 0xad33; REG_DWORD
Log= 0; REG_DWORD
Wn:= 88; REG_SZ


Any ideas why it does not work?

 
Any ideas why it does not work?
The syntax I gave you is for 3rd occurrence of the pattern in the SAME line.
You may consider something like this:
sed '/Cache=/,/Log=/{;/^Tcp Port=/s/0xad33;/1xad11;/;}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

This works great... I had heard of SED Addresses, however, had not tried.

Much Appreciated.
 
Hi,

Slight problem with this sed when I tried to run on Solaris 8...

It works fine on cygwin's implementation of sed - but I get the following error on solaris 8.

sed: command garbled: /Cache=/,/Log=/{;/^Tcp Port=/s/0xad33;/1xad11;/;}

Does this addresses command work on solaris?
 
Hi,

Figured it out - works now ;-)

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top