xargs
ShellAdvanced In simulator In real LinuxBuild command lines from standard input
Name: xargs = extended arguments
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
xargs reads items from standard input (separated by whitespace by default) and runs a command with them as arguments. It bridges commands that take arguments rather than standard input, splitting into several runs when the list is too long.
When file names may contain spaces, pair find -print0 with xargs -0.
Syntax
xargs [OPTION]... [COMMAND [ARG]...]Common options
| -n / --max-args NUM | Max arguments per command |
| -L / --max-lines NUM | Use NUM input lines per command |
| -I {} | Replace {} with each item |
| -0 / --null | Items separated by NUL (with find -print0) |
| -d / --delimiter DELIM | Split the input at DELIM (-d '\n': one item per line, spaces kept) |
| -P / --max-procs NUM | Run up to NUM commands at once (in parallel) |
| -r / --no-run-if-empty | Do not run the command when there is no input |
| -t / --verbose | Show each command before running it |
| -p / --interactive | Prompt before running |