BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

sed command needed please

SOLVED
Go to Solution
Advisor

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

2 REPLIES
Acclaimed Contributor

Re: sed command needed please

Probably something simple like:

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

Highlighted
Acclaimed Contributor

Re: sed command needed please

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