What is xargs in Unix?

We use xargs command to build and execute commands that take input from standard input. It is generally used in chaining of commands.

Xargs breaks the list of arguments into small sub lists that can be handled by a command.

Following is a sample command
:

% find /path -type f -print | xargs rm

The above command uses find to get the list of all files in /path directory. Then xargs command passes this list to rm command so that they can be deleted.

Read the full book at www.amazon.com
Posted in Unix, Unix Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*