xargs dry run searches spike when a find … | xargs rm pipeline almost went wrong. Learn xargs pipelines first; this page is the safety layer.
Print the command
xargs -t echoes each invocation to stderr before it runs.
bashtrace
printf 'a\nb\n' | xargs -t -I{} echo file {}

Echo instead of act
Swap the command for echo to see arguments.
bashpreview
find /var/log -name '*.gz' -mtime +30 -print | xargs echo rm -f

Confirm each batch
xargs -p prompts once per line of input (interactive).
WarningDo not use
-p in cron — only for interactive shells.
Limit width
xargs -n 1 runs one file at a time — easier to audit and recover.
bashone
find ./work -type f -name '*.tmp' -print | xargs -n 1 -t rm -f

Quick Reference
- Basics: xargs pipelines
- Find patterns: find delete old files
Related tutorials
Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.