Search This Blog

Sunday, July 15, 2018

Xargs

Xargs is a command line utility for building an execution pipeline from standard input.
Tools that cannot accept standared input as a parameter (e.g rm , echo , mkdir etc.) Xargs allows them to take standared input as a parameter.

Example :

[Command]
~ echo 'foo bar' | xargs mkdir 
It creates two directories named foo and bar.

[Command]
~ echo 'foo bar' | xargs -t rm -r 
rm -r foo bar 
It removes foo and bar directories.

[Options]
-t : prints command that will be executed to the terminal.