Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

xargs

Build and execute commands from stdin

Syntax

xargs [OPTION]... COMMAND [INITIAL-ARGS]...

Common Options

-I {}Replace string with input line
-n NMax N args per line
-d DELIMSpecify delimiter
-0Null delimiter (with find -print0)
-pPrompt before execution
-tPrint command before executing
-rDon't run if no input
-L NExecute once per N lines
-P NRun N processes in parallel
-s SIZEMax command line size

Common Examples

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

Delete all log files

find . -print0 | xargs -0 rm

Safe delete (handle special chars)

cat urls.txt | xargs -n 1 curl -O

Download URLs one by one

echo "file1 file2" | xargs -n 1 cp -v target/

Copy files one by one

find . -name "*.js" | xargs -I {} mv {} ./js/

Move JS files to directory

ls *.jpg | xargs -I {} convert {} {}.png

Batch convert image format

find . -type f | xargs -P 4 -I {} gzip {}

Parallel compress with 4 workers

echo "a b c d" | xargs -n 2

2 args per line

Related Commands

Related Tools

More Code & Dev Tools