xargs -t: Echo Each Command Before Running
xargs -t prints each constructed command to stderr right before it runs.
When a pipeline does something unexpected, -t shows the exact command lines xargs is building, which is the fastest way to see how items were grouped.
What it does
xargs -t (trace) writes each command, with its assembled arguments, to standard error immediately before executing it. The command still runs normally; -t only adds the echo. It pairs well with -n and -P to confirm how items were batched.
Common usage
find . -name '*.test.js' | xargs -t -n 5 node --test
echo "a b c" | xargs -t -n 1 echo
# combine with a dry-run-ish pattern
find . -name '*.tmp' | xargs -t -r rmOptions
| Flag | What it does |
|---|---|
| -t | Echo each command to stderr before running it |
| (with -n) | Shows how items were grouped per run |
| (with -P) | Traces each parallel command line |
| -p | Like -t but prompts before each run (interactive) |
In CI
Turn on -t while debugging a flaky bulk step so the runner log records the precise commands xargs ran. Because -t writes to stderr, it does not corrupt stdout you may be capturing, and you can drop it once the pipeline is understood.
Common errors in CI
People mistake -t for a dry run: it still executes the command. For a true preview, echo the command, for example "... | xargs -n 1 echo rm", which prints what would run without running it. Under -P the traced lines interleave with output, which is expected.