Reputation: 141110
I have a Perl script called replaceUp:
#!/usr/bin/perl
search=$1
replace=$2
find . -type f -exec perl -p -i -e "s/$search/$replace/g" {} \;
The script does not get loaded. This suggests me that my script is wrong.
How can you make a shell script using Perl?
Upvotes: 1
Views: 710
Reputation: 124267
The first line should be #!/bin/sh
, not #!/usr/local/bin/perl
. You are mistaken that that is a Perl script; it is a shell script that calls Perl.
It's also not going to actually work because $search and $replace are not going to get interpolated inside single quotes. Try single quotes inside double quotes.
Or better yet, try my mass search/replace Perl script. I keep a pure-Perl script for this around because, dangerous as mass search/replace is, you don't need multiple levels of shell metacharacter interpretation taking it from dangerous to absolutely lethal.
Upvotes: 10