linux/xargs

Build Command Lines

Build and execute command lines from standard input

command
pipeline
execution

Command

xargs

Explanation

xargs reads items from standard input and executes commands with those items as arguments.

Examples

Delete all .txt files

find . -name "*.txt" | xargs rm

List files from input

echo "file1 file2" | xargs ls -l

Copy files to backup

cat files.txt | xargs -I {} cp {} backup/