Operating System - HP-UX
1753863 Members
7252 Online
108809 Solutions
New Discussion

sed command needed please

 
SOLVED
Go to solution
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 2
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.