xargs command in Linux

xargs command is used to execute the command with dynamic arguments. Same command is executed for each argument one by one.

Some commands in Linux fail with error message saying “argument list too long”. We can use “xargs” command in such scenarios as command will be executed one one argument at a time.

In below example, find command finds out all files with name matching “hi*” and contents are displayed on standard output stream.

find -maxdepth 1 -type f -name “hi*” | xargs cat

You may also like...