Home: Perl Programming Help: Regular Expressions:
Substitution does not work on multiple files



jokibar
New User

Aug 20, 2012, 5:40 AM


Views: 10038
Substitution does not work on multiple files

Hello,

I need to change an email addresse in ca. 800 files.
I tried this:

Code
perl -pi -e 's/Old@email.com/New@email.com/g'

That command worked for a while but unfortunately didn't change anything.

Is my version too old?


Code
perl -v This is perl, v5.8.4 built for sun4-solaris-64int



Laurent_R
Veteran / Moderator

Aug 20, 2012, 6:04 AM


Views: 10037
Re: [jokibar] Substitution does not work on multiple files

You failed to give the name of the files to be changed.

It should be something like this:


Code
perl -pi -e 's/Old@email.com/New@email.com/g' filename*.*



jokibar
New User

Aug 20, 2012, 6:13 AM


Views: 10036
Re: [Laurent_R] Substitution does not work on multiple files

Sorry,

i posted that wrong, what I did was:


Quote
perl -pi -e 's/Old@email.com/New@email.com/g' *



jokibar
New User

Aug 20, 2012, 6:28 AM


Views: 10033
Re: [Laurent_R] Substitution does not work on multiple files

I Know what happend: i had to escape the characters: . and @


Laurent_R
Veteran / Moderator

Aug 20, 2012, 10:26 AM


Views: 10022
Re: [jokibar] Substitution does not work on multiple files

Yeah, I should have seen it (I juste made a large program full of regexes on email addresses recently), but my eye was immediately caught by the fact that you did not give input file names.