Re: sed command needed please (187 Views)
Reply
Advisor
Dadski
Posts: 17
Registered: ‎01-08-2009
Message 1 of 3 (407 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

Acclaimed Contributor
Dennis Handly
Posts: 25,277
Registered: ‎03-06-2006
Message 2 of 3 (402 Views)

Re: sed command needed please

Probably something simple like:

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

Acclaimed Contributor
Dennis Handly
Posts: 25,277
Registered: ‎03-06-2006
Message 3 of 3 (187 Views)

Re: sed command needed please

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

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.