Files & folders · Delete safely
Look before you delete
Deleting is instant and there's no undo, so make a habit of it: preview a wildcard with ls first, read the list, then run rm with exactly the same pattern.
Why: a pattern can match more than you think. If the list surprises you, the delete would have too.
Worked example
learner@shellstreak:~/tidy$ ls *.log
old-1.log
old-2.logWhat the output means
old-1.logandold-2.log: exactly whatrm *.logwould delete. Nothing else matches, so it's safe.
Common mistakes
- Previewing one pattern and deleting with another (a typo in the second one).
- Skipping the preview "just this once".
Tap Run to preview which files *.log matches in this messy folder.
Try it:
ls *.loglearner@shellstreak: ~
Starting your practice shell…
You can also type in the terminal yourself. Try anything: you can't break it.
Go deeper: Basic terminal commands for beginners