APM: Modify in place and Argument list too long

Wayne Walker wwalker at broadq.com
Mon Mar 17 13:15:08 CST 2003


On Mon, Mar 17, 2003 at 10:53:13AM -0800, Marc Majcher wrote:
> 
> dbii at mudpuddle.com (David Bluestein II):
> 
> :I'm doing a perl modify in place for a directory full of html files, yet I
> :have several directories which have too many files for this:
> :
> :bash# perl -pi -e 's/oldtext/newtext/g' *html
> :bash: /bin/perl: Argument list too long
> 
> Use find.  Something along the lines of:
> 
> find /path/to/dir -name "*html" -exec perl -pi -e 's/oldtext/newtext/g' {} \;

One gotcha:  the \ in front of the semi-colon is mandatory!

Marc's solution is just as functional as the xargs solution I mentioned
and more straight forward than mine.  once you understand both, you'll
know when to use one versus the other...

The difference is that this will execute the script 60,000 times with
only one filename each time.  This is often exactly what you want.
In the case of "one filename per invocation" use Marc's recommendation.
When you want a few invocations with lots of file names, use xargs.

> 
> Works slightly differently on different systems.  Consult your man.
> 
> -- 
> DVS
> THERE COULD BE BUGS IN EVERY SINGLE MEAL YOU EAT!!!
> _______________________________________________
> Austin mailing list
> Austin at mail.pm.org
> http://mail.pm.org/mailman/listinfo/austin

-- 

Wayne Walker

www.broadq.com :)  Bringing digital video and audio to the living room



More information about the Austin mailing list