Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

sed command needed please

SOLVED
Go to solution
Highlighted
Dadski
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
Dennis Handly
Acclaimed Contributor
Solution

Re: sed command needed please

Probably something simple like:

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

Dennis Handly
Acclaimed Contributor

Re: sed command needed please

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