start page | rating of books | rating of authors | reviews | copyrights

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 9.20 Too Many Files for the Command Line Chapter 9
Saving Time on the Command Line
Next: 9.22 xargs: Problems with Spaces and Newlines
 

9.21 Handle Too-Long Command Lines with xargs

xargs is one of those UNIX utilities that seems pretty useless when you first hear about it - but turns into one of the handiest tools you can have.

xargs
If your system doesn't already have xargs , be sure to install it from the CD-ROM.

xargs reads a group of arguments from its standard input, then runs a UNIX command with that group of arguments. It keeps reading arguments and running the command until it runs out of arguments. The shell's backquotes ( 9.16 ) do the same kind of thing, but they give all the arguments to the command at once. This can give you a Too many arguments ( 9.20 ) error.

Here are a couple of examples:

As the next article ( 9.22 ) explains, xargs can have trouble if an argument has white space inside a word. Luckily, the GNU xargs (read about it there) solves the problem.

- JP


Previous: 9.20 Too Many Files for the Command Line UNIX Power Tools Next: 9.22 xargs: Problems with Spaces and Newlines
9.20 Too Many Files for the Command Line Book Index 9.22 xargs: Problems with Spaces and Newlines

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System