Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Open Files in Unix

by superfrink (Curate)
on Oct 08, 2008 at 19:16 UTC ( #716073=note: print w/replies, xml ) Need Help??


in reply to Open Files in Unix

I would use something like the following command line.
find -name cynlogging.properties -exec perl -p -i.backup -e 's/search/ +replace/g' {} \;
For example:
$ mkdir x $ cd x $ mkdir b $ date > asdf $ date > b/asdf $ cat asdf Wed Oct 8 13:11:35 MDT 2008 $ find . -name asdf -exec perl -p -i.backup -e 's/1/XXX/g' {} \; $ cat asdf Wed Oct 8 XXX3:XXXXXX:35 MDT 2008 $ cat b/asdf Wed Oct 8 XXX3:XXXXXX:37 MDT 2008 $ cat asdf.backup Wed Oct 8 13:11:35 MDT 2008

Replies are listed 'Best First'.
Re^2: Open Files in Unix
by swartzieee (Initiate) on Oct 08, 2008 at 20:04 UTC
    to run as a perl script do i do system ("find -name cynlogging.properties -exec perl -p -i.backup -e 's/search/ +replace/g' {} \");

      I personally believe that if this is a question, then it should be marked with... a question mark. Anyway, the answer is yes, or at least that is a possible way to do it. (Except that, as a minor point, you should quote the backslash.) But more importantly why, precisely, should you run the above line "as a perl script?" The whole point was that probably a single find(1) command is better suited to your need than a whole Perl program. (Although one may consider there that perl is called multiple times in the second case, and this includes a overhead... probably a completely irrelevant consideration, in this particular situation - and there are simple cures, anyway.)

      --
      If you can't understand the incipit, then please check the IPB Campaign.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://716073]
help
Chatterbox?
[pryrt]: matches neither. :-)
[stevieb]: wtf!? lol
[stevieb]: I'm checking some other versions. This is a little frightening
[pryrt]: Sorry, my bad: it was't done downloading when I did the sha1sum... now I match your 309ad... value
[stevieb]: I'll see how to get in touch with someone and advise that there's an issue. Thanks for helping me confiirm pryrt!

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2017-03-29 21:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (353 votes). Check out past polls.