D&C GLug - Home Page

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

Re: [LUG] Help with sed

 

a couple of largely random thoughts due to rusty memory

* with sed you can use -e multiple times
* awk is more flexible and has a getline command

Steve

2008/10/21 kevin <kevin.lucas@xxxxxxxxxxxxxxxxxx>:
> I am coming to that idea also
>
> I am going to have to loop the whole Dir 421 files
> look for all the different ways/methods/ syntax I have connected to the
> Db in the past 6 years and make a common connection out the lot in an
> include file
> All the loops I have tried so far have trashed the Dir with rubbish!
> (It's a good job I havn't looped it round the real working Dir!)
>
> So I think I will have to make an array with everything I want to find,
> then loop around each file taking it out and putting back an include
> statement.
> The lesson here is when you start a project make it scalable even if you
> don't think anyone else will want to look at it in years to come!
>
>
> On Tue, 2008-10-21 at 20:19 +0100, Grant Sewell wrote:
>> 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.
>>
> 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
>



-- 
Steve Lee
Open Source Assistive Technology Software and Accessibility
fullmeasure.co.uk

-- 
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