Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: tlug: Re: search & replace (was: Grep for subdirectories?)
- To: tlug@example.com
- Subject: Re: tlug: Re: search & replace (was: Grep for subdirectories?)
- From: Scott Perlman <perlman@example.com>
- Date: Mon, 5 Oct 1998 15:52:10 +0900
- Content-Type: text/plain; charset=us-ascii
- In-Reply-To: <19981005151819.A10276@example.com>; from Rex Walters on Mon, Oct 05, 1998 at 03:18:19PM +0900
- References: <36175E56.CF2B701@example.com> <Pine.LNX.3.96LJ1.1b7.981005093914.621j-100000@example.com <3.0.6.32.19981005123400.0095c7c0@example.com> <19981005134228.A10159@example.com> <19981005143016.C3664@example.com> <19981005151819.A10276@example.com>
- Reply-To: tlug@example.com
- Sender: owner-tlug@example.com
Rex Walters did state upon Mon, Oct 05, 1998 at 03:18:19PM +0900: > On Mon, Oct 05, 1998 at 02:30:16PM +0900, Scott Perlman wrote: > > actually, just in the spirit of the subdirectories it should probably be > > find . -name '*.html' -e 'perl -pi.bak -e "s/match/replace/" {} ;' > > > > (all that is is wrapping The provided perl witha find) > > Actually, to be pedantic, Darren wrote: > > > > > I've a similar question: How do I do a search and replace operation on > > > > files? > > Thus I didn't specifically include any recursion into sub-directories. > > But if you really wanted to do the search and replace on all the .html > files in an entire directory *tree*, you might be better off doing it > differently from how you've described unless you're quite certain that > there are only a few .html files. > > The problem is that yours will fire off a new perl process for each and > every .html file found. This can be pretty slow on a under-powered > (under-memoried) machine. With only 200 html files it probably doesn't > matter (but if they are *big* html files ... ;-). > > 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, find . -name '*.html' -print | xargs perl -pi.bak -e "s/match/replace/" Now you've got one perl process (or one per however many arguments xargs supports) And the question was how to find the files in recursed directories, with a followup of how to operate on them.. -Scott (who hasn7t had to do enough real programming to learn all of the modules andstuff for perl or anything else, but has picked up some shell tricks here and there) -- Why are we here? Because we're here! | Scott H. Perlman Roll The Bones!! --RUSH | SH-T CRAPS AGAIN!!!!!!! | perlman@example.com --------------------------------------------------------------- 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
- Follow-Ups:
- Re: tlug: Re: search & replace (was: Grep for subdirectories?)
- From: Rex Walters <rex@example.com>
- References:
- tlug: Grep for subdirectories?
- From: Neil Booth <NeilB@example.com>
- tlug: Re: search & replace (was: Grep for subdirectories?)
- From: Rex Walters <rex@example.com>
- Re: tlug: Re: search & replace (was: Grep for subdirectories?)
- From: Scott Perlman <perlman@example.com>
- Re: tlug: Re: search & replace (was: Grep for subdirectories?)
- From: Rex Walters <rex@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: tlug: Network Question
- Next by Date: Re: tlug: Network Question
- Prev by thread: Re: tlug: Re: search & replace (was: Grep for subdirectories?)
- Next by thread: Re: tlug: Re: search & replace (was: Grep for subdirectories?)
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links