On Wed, 6 Oct 2004, Bil Kleb wrote:

> David Heinemeier Hansson wrote:
>> Bil wrote:
>>> I.e., why isn't this a ruby command instead of sed?
>>>
>>>  $ sed -i '/^#!/{s,local/,,}' public/dispatch.{cgi,fcgi,rb}
>>
>> That's the wonderful power of the wikis. You perceive this as a bug and
>> with the Edit link at the bottom of the page, you have the power to
>> change it! So I expect to see a new revision of that page edited by Bil
>> Kleb shortly ;)
>
> I would, but let the truth be known: My command-line ruby is so poor that
> my sed equivalent is too Perl:
>
>  ruby -pi -e \$_.sub\!\(/^\(#\!.*\)local\\\//,\'\\\1\'\) public/dispatch.{rb,cgi,fcgi}
>
> due to trouble with getting '\1' inside the argument to -e when using bash.
>
> The following is cleaner but does not follow the sed command's behavior
> and is still too Perlish for my tastes:
>
>  ruby -pi -e '$_.sub!(/local\//,"") if $_=~/^#!/' public/dispatch.{rb,cgi,fcgi}
>
> Anyone?

perhaps

   ruby -p -ibak -e '$_.sub! %r|^(#!.*)local/|, "\\1"' public/dispatch.{rb,cgi,fcgi}

??

-a
--
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it. 
|   --Dogen
===============================================================================