Dangerous Commands
Risk: cautionPrint a Dry-Run Removal Script
You have cleanup candidates and need a human-reviewable removal plan instead of executing deletion directly from find.
Command
find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n'
Before you run this
Risk: caution. Do not pipe generated removal commands into a shell; review, quote, and execute intentionally if cleanup is approved.
Expected output
One printed rm -i command per old cleanup candidate.
System impact
Nothing changes. The command prints interactive rm commands as text and does not execute them.
When to use it
Use when turning a candidate list into a reviewed cleanup plan for a small, well-understood path.
When not to use it
Do not pipe generated removal commands into a shell; review, quote, and execute intentionally if cleanup is approved.
Recovery / rollback
No undo needed for the dry run. If a printed command is later executed, restore from backup or the source system.
Watch this command run
Example output from a temporary Linux lab
This example uses disposable sample files and sanitized output so you can inspect the shape of the result before touching a real system.
$ find /work/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %p\n' | sort
2026-06-01 /work/disk-inode-cleanup/var/tmp/uploads/old-export.tar
$ find /work/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n'
rm -i -- /work/disk-inode-cleanup/var/tmp/uploads/old-export.tar
View reproducible demo details
This page shows the sanitized shell transcript and the setup steps needed to reproduce the example.
Lab setup steps
find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %p\n' | sortfind /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n'
next steps
Related commands
Preview Old Temp Files Before Deleting
The safe version of cleanup is a candidate list first.
find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' | sort
Rank Old Cleanup Candidates by Size
The oldest file is not always the file that buys back meaningful space.
find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
Review Log Files Before Cleanup
Before truncating logs, prove which log files are large and how old they are.
find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr
Find Directories Burning Inodes
Inode cleanup starts by finding the directory with too many files.
find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
Summarize Cache File Ages
Cache cleanup is safer when you know whether files are stale or still active.
find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.