sed command needed please (386 Views)
Reply
Advisor
Dadski
Posts: 17
Registered: ‎01-08-2009
Message 1 of 3 (386 Views)
Accepted Solution

sed command needed please

Morning All,

 

I am writing a remediation script to a very tight deadline accross HPUX, Solaris and AIX, and am looking for something that I am sure is pretty easy but isconsuming lots of my time.

 

I am looking to edit a text file using sed. base on different conditions,  so a file may have the following different entries.

 

DICTIONDBDIR=/var/passwd

#DICTIONDBDIR=/var/passwd

DICTIONDBDIR=/var/passwd/helpme

DICTIONDBDIR=/var/passwd/elvis/is/alive

 

etc

 

I want to simply replace any of these with

 

DICTIONDBDIR=/var/passwd

 

using sed, any ideas?

 

thanks  very much

 

Martin

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 25,002
Registered: ‎03-06-2006
Message 2 of 3 (381 Views)

Re: sed command needed please

Probably something simple like:

sed -e 's:.*DICTIONDBDIR=/var/passwd.*$:DICTIONDBDIR=/var/passwd:' file > file.new

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 25,002
Registered: ‎03-06-2006
Message 3 of 3 (166 Views)

Re: sed command needed please

Besides marking my post as a solution, it would nice if you also assigned kudos.

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation