Software & Apps Linux Uses of the "xargs" Command Use 'xargs' when a standard pipe or redirection symbol won't work by Juergen Haas Writer Former Lifewire writer Juergen Haas is a software developer, data scientist, and a fan of the Linux operating system. our editorial process Juergen Haas Updated on February 20, 2020 Tweet Share Email Linux Switching from Windows The xargs command is typically used in a command line where the output of one command is passed on as input arguments to another command. In many cases, no special command such as xargs is needed to accomplish that purpose, because the pipe and redirection operators perform the same type transaction. However, sometimes you'll experience glitches with the basic piping and redirection mechanism—e.g., if arguments contain spaces. Additionally, xargs executes the specified command repeatedly, if necessary, to process all the arguments given to it. In fact, you can specify how many arguments should be read off the standard input stream each time xargs executes the specified command. When to Use It In general, use the xargs command if the output of one command serves as part of the options or arguments of a second command to which the data are streamed (using the pipe operator "|"). Regular piping is sufficient if the data are intended to serve as the standard input of the second command. For example, use the ls command to generate a list of file names and directories, then pipe this list into the xargs command executing wc. You'll obtain the word counts of each of the specified files: ls *.txt | xargs wc If you execute a command that returns a large and unpredictable number items (e.g. file names) which are passed on to another command for further processing, it is a good idea to control the maximum number of arguments that second command receives to avoid overload and crashing. Was this page helpful? Thanks for letting us know! Get the Latest Tech News Delivered Every Day Email Address Sign up There was an error. Please try again. You're in! Thanks for signing up. There was an error. Please try again. Thank you for signing up. Tell us why! Other Not enough details Hard to understand Submit