O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.2. Xargs

When using the -exec option in find to process files, find passes all the located files to exec to be worked on in one go. Unfortunately on some systems there is only a limited command line length that can be passed to exec before it bombs out after running for a few minutes with an error message. The error message usually says ‘Too long on Args list’ or ‘Args list exceeded’. This is where xargs comes in, especially when using find. Find passes on the located files to xargs and xargs grabs the files in portions and not all in one go, unlike using exec. Thus it can process the first portion of files, do its stuff, then request the next batch of the files and so on.

Let’s see how xargs fits in with some find examples.

The following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required