Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Automatically Rewrite Shebang Line on Multiple Files

by ikegami (Pope)
on Feb 11, 2009 at 22:08 UTC ( #743187=note: print w/replies, xml ) Need Help??


in reply to Re: Automatically Rewrite Shebang Line on Multiple Files
in thread Automatically Rewrite Shebang Line on Multiple Files

for %q in (*.cgi *.pl) do ( perl -pi.bak -e"s{^#!/usr/bin/perl}{#!/usr/local/bin/perl}" "%q" )

Change for to for /r for a recursive solution.

Update: Simplified solution

Replies are listed 'Best First'.
Re^3: Automatically Rewrite Shebang Line on Multiple Files
by spickles (Scribe) on Feb 16, 2009 at 22:22 UTC
    Your solution with a for loop has the word perl within it. Is this a script in a language other than perl, or is there some significance to the use of "perl -pi.bak"? I'm not familiar with cygwin - the last time I tried to install it something didn't work right.

    Regards,
    Scott

      Is this a script in a language other than perl

      It's a Windows shell (cmd) command. If you need it in a batch file, you need to escape the %. Change %q to %%q.

      I'm not familiar with cygwin

      Cygwin is a OS emulator, not a shell or a scripting language. When people say Cygwin, they usually refer to bash and/or GNU tools. samtregar showed that a solution can be obtained using bash and GNU tools. I showed that such tools weren't required.

      is there some significance to the use of "perl -pi.bak"

      It invokes perl. -p and -i are documented in perlrun.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://743187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2020-08-15 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (78 votes). Check out past polls.

    Notices?