Deleting files (rm command)

Use the rm command to remove files you no longer need.

The rm command removes the entries for a specified file, group of files, or certain select files from a list within a directory. User confirmation, read permission, and write permission are not required before a file is removed when you use the rm command. However, you must have write permission for the directory containing the file.

The following are examples of how to use the rm command:
  • To delete the file named myfile, type the following:
    rm myfile
  • To delete all the files in the mydir directory, one by one, type the following:
    rm -i mydir/*
    After each file name displays, type y and press Enter to delete the file. Or to keep the file, just press Enter.

See the rm command in the Commands Reference, Volume 4 for the complete syntax.