APM: Modify in place and Argument list too long

Wayne Walker wwalker at broadq.com
Mon Mar 17 13:05:40 CST 2003

On Mon, Mar 17, 2003 at 12:57:34PM -0600, David Bluestein II wrote:
> 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

ls | grep '\.html$' | xargs perl -pi -e 's/oldtext/newtext/g'

xargs is part of the "find" package.  Arg list too long comes from the
kernel settings and can't be easily changed.  xargs takes __words__ on
standard input and makes them arguments and passes then to as many
invocations of the program as needed.

> Any suggestions on how to work with this? The most files in a directory are
> 60,000.

In this case, then perl -pi... will probably be invoked about 30 times
with roughly 2000 args each time (unless the filenames are long, then
more invocations with fewer args each).

> David
> ----------
> David H. Bluestein II                         President & Lead Developer
> dbii at interaction.net                         ii, inc.
> http://www.interaction.net
> -        Specializing in Designing Interactive Websites        -
> -              and Searchable Internet Databases                   -
> _______________________________________________
> 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