CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



jokibar
New User

Aug 20, 2012, 5:40 AM

Post #1 of 5 (3528 views)
Substitution does not work on multiple files Can't Post

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
Enthusiast / Moderator

Aug 20, 2012, 6:04 AM

Post #2 of 5 (3527 views)
Re: [jokibar] Substitution does not work on multiple files [In reply to] Can't Post

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

Post #3 of 5 (3526 views)
Re: [Laurent_R] Substitution does not work on multiple files [In reply to] Can't Post

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

Post #4 of 5 (3523 views)
Re: [Laurent_R] Substitution does not work on multiple files [In reply to] Can't Post

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


Laurent_R
Enthusiast / Moderator

Aug 20, 2012, 10:26 AM

Post #5 of 5 (3512 views)
Re: [jokibar] Substitution does not work on multiple files [In reply to] Can't Post

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.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives