I need to replace text in all the files in one of my folders and am using Perl but getting an error.
This is what I am running:
perl -pi.bak -e 's/<START>/<url><loc>http://www.mysite.com/page//g' *
Basically I just need to replace
<START>
with this:
<url><loc>http://www.mysite.com/page/
And this is the error I'm getting:
Illegal division by zero at -e line 1, <> line 1.
Can someone tell me what I should be doing? I've also tried several other methods but none seem to be working... I really need it to be done via command line so that it's faster because there are over ten million lines. Thanks!
The /es in your replacement text are being virewed as delimeters, and also as the division operator. You can either escape the slases as \/ where appropriate, or use alternate delimeters. Try:
perl -pi.bak -e 's#<START>#<url><loc>http://www.mysite.com/page/#g' *
You need to escape slashes.
s/<START>/<url><loc>http:\/\/www.mysite.com\/page\//g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With