Removing Files with rm

You can easily—perhaps too easily—remove (delete) files from your Unix system. As Murphy will tell you, it’s a good idea to think twice before doing this; once you remove a file, it’s gone (unless, of course, you plead with your system administrator to restore it from a backup tape—but that’s another story). At any rate, it’s permanent, unlike deletions in Windows or the Macintosh OS, where the Recycle Bin or Trash give you a second chance.

You remove files using rm, as shown in Code Listing 2.9. And, as you’ll see in the following steps, you can remove files one at a time or several at a time.

Code Listing 2.9. Use rm -i to safely and carefully remove directories and files.
$ ls Completed oldfile Newfile soon.to.be.gone.file ...

Get Unix Third Edition: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.