Re: [SLUG] Need help with a sed script

From: Russ Wright (rwrigh10@tampabay.rr.com)
Date: Sat Aug 02 2003 - 13:14:41 EDT


Thanks for the reply!
Yes that does seem to work well.

One issue I just realized. The files are split up in multiple subdirectories
how could I modify the script to go into each subdirectory and do the same?

Regards
Russ

On Saturday 02 August 2003 11:48 am, btt@nethouse.com wrote:
> On Sat, Aug 02, 2003 at 09:56:35AM -0400, Russ Wright wrote:
> > Hey all
> > I have a simple script to perform a find and replace for me. Currently
> > it looks for "<?" and replaces it with "<?php".
> >
> > for fl in *.php; do
> > mv $fl $fl.old
> > sed 's/<? /<?php /g' $fl.old > $fl
> > rm -f $fl.old
> > done
> >
> > Works pretty well.
> >
> > However I need to make it a little smarter. I need the script to find
> > any of the following "<? ", "<?=", "<?(carriage return)" and replace
> > it with <?php. However it must not replace "<?php" with "<?phpphp".
>
> This seems to work:
>
> $ perl -p -i'.orig' -e 's/\<\?[^\s]*(\s)/\<?php\1/g' *.php
>
> It wants to replace <? and anything after it including the first
> whitespace it finds with <?php and whatever whitespace it found. I
> think that should do it. It will make little backups of each file
> appending '.orig' to each one in case this thing runs amok :)
>
> Good luck!
> -----------------------------------------------------------------------
> This list is provided as an unmoderated internet service by Networked
> Knowledge Systems (NKS). Views and opinions expressed in messages
> posted are those of the author and do not necessarily reflect the
> official policy or position of NKS or any of its employees.

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:56:00 EDT