[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Tue, 2008-10-21 at 20:07 +0100, James Fidell wrote: > 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. > > It may not work fine, depending on what you expect it to do :) > > sed -e '/$host/,/$database/d' > > will delete all lines from one containing "$host" to one containing > "$database". > > > but sed -e > > '/$host/,/$database/,/$user/d' addveg.php > more.txt > > fails. Am I on the right lines or not? > > The "d" command in sed takes at most two parameters, so that's > never going to work. > > What you probably want is something like: > > sed -e '/$database *=/d' -e '/$host *=/d' -e '/$user *=/d' > > though if you have ten different strings to delete I'd be more tempted > to use egrep I think, so you can chain all the different variables into > a single regex. Obviously perl would do the job nicely, too, if it > isn't too busy making the dinner and solving the world's financial > crisis. > > James > Thanks James that's the bit I was getting wrong! Deleting from - to I thought it deleted the First then the Second and Hopefully the Third..... Perl is for me less familiar than SED! Regards Kevin Lucas Minions Post Master(Sub) reprieved (possibly!) Po House, Minions, Liskeard Cornwall PL14 5LE 01579363386 -- 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