in reply to Automatically Rewrite Shebang Line on Multiple Files
This is very easy if you've got cygwin to give you a working shell, find and xargs. For example, to change from /usr/bin/perl to /usr/local/bin/perl I'd do something like (untested):
find -name '*.pl' -o -name '*.cgi' | xargs perl -pi -e "s{^#!/usr/bin/perl}{#!/usr/local/bin/perl}"
The -pi command-line switch tells Perl to do in-place editing and the -e specifies the code to on each line. If your filenames might have spaces in them you can add -print0 to the find call and -0 to the xargs call before perl.
If you want to do it all in Perl can use File::Find or something similar to find the files for you.
-sam
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Automatically Rewrite Shebang Line on Multiple Files
by ikegami (Patriarch) on Feb 11, 2009 at 22:08 UTC | |
by spickles (Scribe) on Feb 16, 2009 at 22:22 UTC | |
by ikegami (Patriarch) on Feb 16, 2009 at 23:30 UTC | |
Re^2: Automatically Rewrite Shebang Line on Multiple Files
by linuxer (Curate) on Feb 11, 2009 at 21:53 UTC | |
by samtregar (Abbot) on Feb 11, 2009 at 22:07 UTC |
In Section
Seekers of Perl Wisdom