[aclug-L] Re: sed or awk??? or better way to do.
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
I've never used sed, but it might be the sort of thing to use for that.
Someone more knowledgable in sed should speak up on that.
Personally, the first thing I thought of was a Perl hash, which stores
pairs of values. All you'd need to do is store the file of matched pairs,
read it into a hash, and then read through an input file, replacing every
occurance of "bad" with "good". If you set up your regular expression
correctly to identify blank space, it won't replace "badly", etc...
It should make a pretty short Perl program, actually.
John
On Fri, 3 Nov 2000, Maverick Ieong wrote:
> Hi, all
> I have a file call table.txt and inside it contain:
> //this is the table.txt
> old new
> bad good
> oldstuff newstuff
> ... ...
>
> I would like to read in a text file. for example,
> //this is a text.file
> I am old, and I am bad, badly,
> old stuff and bad stuff
> ...................
> ..............
>
>
> and replace all the occurence the word accordingly to
> on the same text file, like
> //this is a text.file
> I am new, and I am good, badly,
> new stuff and good stuff
> .....................
> ...............
>
>
> note, I only want to replace the exactly accordingly,
> for example, the word "badly" didn't replace by
> "goodly".
>
>
> Is that a simple way to do it?
> Thanks,
>
> Regards,
> Mav
>
>
> =====
> ~:~:~:~:~:~:~~:~:~:~:~:~:~~:~:~:~:~:~:~~:~:~:~:~:~:~~:~:~:~:~:~:~
>
> __________________________________________________
> Do You Yahoo!?
> >From homework help to love advice, Yahoo! Experts has your answer.
> http://experts.yahoo.com/
>
> -- This is the discussion@xxxxxxxxx list. To unsubscribe,
> visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
>
-- This is the discussion@xxxxxxxxx list. To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
|
|