__/ [John A.] on Friday 21 October 2005 03:44 \__
> On Thu, 20 Oct 2005 20:09:40 +0100, Brian Wakem <no@xxxxxxxxx> wrote:
>
>>wd wrote:
>>
>>> This is a little script that I use a lot, just changing one or two lines
>>> depending on the task I need done. I'm just a beginner so there might be
>>> much better ways to do it, but this works for ampersands, and will also
>>> work for your other example with a simple change.
>>
>>
>>A one-liner will do the job:
>>
>>perl -p -i -e 's!&!&!g' filename
>>
>>or
>>
>>perl -p -i -e 's!&!&!g' *.html
>>
>>to change in all html files in the current directory.
>
> Would that also change all instances of "&" in all the html files
> in the directory to "&amp;"?
>
> (And " " to "&nbsp;", etc...)
Only if you run it more than once.
It is not recursive (tail recursion where the head expands) unless you re-
quest for it to behave that way. That's a very good observation, which of-
ten justifies keeping a copy before applying any batch-mode changes. It is
otherwise quite irreverisble, unless you are willing to script something
just to make up for a foolish mistake. Been there, seen that. *smile*
Roy
--
Roy S. Schestowitz | "On the eighth day, God created UNIX"
http://Schestowitz.com | SuSE Linux | PGP-Key: 74572E8E
4:50am up 56 days 17:04, 6 users, load average: 0.15, 0.42, 0.68
http://iuron.com - next generation of search paradigms
|
|