Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: Re: search & replace (was: Grep for subdirectories?)



On Mon, Oct 05, 1998 at 03:52:10PM +0900, Scott Perlman wrote:
> Rex wrote:
> > 
> > Better would be to do the recursion/inode-walk within perl (the find
> > module is useful for this) or to feed the filenames into stdin.  Both
> > options are sufficiently ugly as a one liner that I would probably break
> > down and write a real script.  :-)
> > 
> 
> Actually no, 

No, what?  An inode-walk/find within perl or getting the filenames from
stdin wouldn't be better than invoking a perl process for every html
file found?

I think I may have somehow irritated you.  Apologies if so.

> find . -name '*.html' -print | xargs perl -pi.bak -e "s/match/replace/"

This is exactly what I meant about feeding the filenames to stdin.
You've chosen to use another external program (xargs), but I 
would probably do the same for a one-off like this.

> Now you've got one perl process (or one per however many arguments
> xargs supports)

To be pedantic, one find process, n xargs processes, and n perl
processes.  Absolutely better than the original, but it can still all be
done in perl (I refuse to think about any problems that *CAN'T* be done
in perl :-).

> And the question was how to find the files in recursed directories,
> with a followup of how to operate on them..

No, as I was so careful to quote in my previous message, the question I
was responding to mentioned nothing about recursed directories, it was
purely a "by the way, how do I do this" question. 

Regards,
-- 
Rex

P.S.  Anybody know of anything similar to supercite.el for vim?  Sorry,
      the neural pathways to my fingers have atrophied to the point that 
      learning emacs is no longer feasible.
---------------------------------------------------------------
Next Meeting: 10 October, 12:30 Tokyo Station Yaesu central gate
Featuring the IMASY Eng. Team on "IPv6 - The Next Generation IP"
Next Nomikai: 20 November, 19:30  Tengu TokyoEkiMae 03-3275-3691
---------------------------------------------------------------
Sponsor: PHT, makers of TurboLinux http://www.pht.co.jp


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links