D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Help with sed

 

On Tue, 21 Oct 2008 18:54:05 +0100
kevin wrote:

> is it possible to use sed to find more than two different lines of a
> file.
> ie I am having to hack out lines like 
> 
> $database="blablabla";
> $host="localhost";
> 
> from many php files 
> I can, using the expression sed -e '/$host/,/$database/d' more.php  >
> more.txt as this woks fine.
> 
> but                                         sed -e
> '/$host/,/$database/,/$user/d' addveg.php  > more.txt
> fails.  Am I on the right lines or not?
> 
> when it works ( I may have up to 10 different lines to remove) i want
> to put in a "include db.ini ;"  statement.
> 
> 
> Regards
> 
> Kevin Lucas

Being a fairly non-coding type person, this may be a daft idea... can
you not loop it replacing a single entry per loop?

E.g.:

for stringtoreplace in 'abc' 'def' 'ghi'
do
  sed -e blah $stringtoreplace blah
done

(Can you tell I'm not a coder?)

Grant.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html