Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [command processing -e] perform substitutions listed in a file on a path

Reply
Thread Tools

[command processing -e] perform substitutions listed in a file on a path

 
 
Hike Mike
Guest
Posts: n/a
 
      07-22-2005
I want to replace strings in a file called .classpath

so i do this:

perl -pi.bak -e "s/ptlEdgeAth/ptlAthEdge/g" .classpath

and it works.

I want to replace strings in all files called .classpath (incuding
sub-directories)

so i do this:

find -name .classpath | xargs perl -pi.bak -e
"s/ptlEdgeAth/ptlAthEdge/g"
and it works.

How do i read a list of substitutions from a file and apply them to all
files named .classpath in all subdirectories?

I tried this:
find -name .classpath | xargs perl -pi.bak -e "diff.txt"

where diff.txt contains the lines:
s/ptlEdgeAth/ptlAthEdge/g
s/ptlEdgeAthDb/ptlAthEdgeDb/g
s/ptlEdgeCore/ptlCoreEdge/g

but it doesn't work

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      07-22-2005
Hike Mike wrote:
> How do i read a list of substitutions from a file and apply them to all
> files named .classpath in all subdirectories?
>
> I tried this:
> find -name .classpath | xargs perl -pi.bak -e "diff.txt"
>
> where diff.txt contains the lines:
> s/ptlEdgeAth/ptlAthEdge/g
> s/ptlEdgeAthDb/ptlAthEdgeDb/g
> s/ptlEdgeCore/ptlCoreEdge/g


You're asking perl to execute the code "diff.txt". But what you meant
to do is ask perl to execute the code contained in the file diff.txt
In other words, you don't want the -e option. You just want to execute
that file.

find -name .classpath | xargs perl -pi.bak diff.txt

Paul Lalli

 
Reply With Quote
 
 
 
 
James Taylor
Guest
Posts: n/a
 
      07-22-2005
In article <(E-Mail Removed) .com>,
Hike Mike <(E-Mail Removed)> wrote:
>
> I tried this:
> find -name .classpath | xargs perl -pi.bak -e "diff.txt"


You don't want the -e unless "diff.txt" is a Perl statement I
don't recognise. The quotes are unnecessary too.

> where diff.txt contains the lines:
> s/ptlEdgeAth/ptlAthEdge/g
> s/ptlEdgeAthDb/ptlAthEdgeDb/g
> s/ptlEdgeCore/ptlCoreEdge/g


You'd better put semicolons at the end of each line too.

--
James Taylor, London, UK PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
virtual directory and hyperlink file path issue (listed and linked paths don't match) Jim in Arizona ASP .Net 0 05-08-2009 05:47 PM
Processing pathnames listed in a text file. Jason Heyes C++ 4 03-24-2005 11:47 AM
using templates as substitutions for #ifdef Chris Goller C++ 4 03-09-2005 12:17 AM
Ant problem with property substitutions. RJGraham Java 6 06-28-2004 03:49 AM
Tkinter: spinbox command and percent substitutions Tony Eva Python 1 11-09-2003 02:25 PM



Advertisments