Using xargs to Process a List of Items

So far in this chapter, you have used filename wildcards to generate file lists on the command line, but that technique can fail (remember the error arg list too long) if there are too many files that match the pattern. Backquotes can be used to generate file lists from a pipeline of UNIX commands, giving you much more control over the files in the list. However, backquotes also can fail if too many filenames are generated, especially on older UNIX systems. The xargs command can succeed where these other techniques failed.

Test Your UNIX Skills

lp *[0-9][0-9]

Use this command to print all (nonhidden) files whose name ends in two or more digits. Assume that this command fails with the error arg list too ...

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.