1/9

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.log

What the output means

  • old-1.log and old-2.log: exactly what rm *.log would 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 *.log
learner@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