How to Delete Files Using the Terminal in Mac OS X

The Mac Terminal in OS X Mavericks uses the "rm" command to delete files, and either "rm" or "rmdir" to delete folders. Unlike the normal "Move to Trash" command, deleting a file or folder is permanent in the Terminal, so use the "mv" command if you want to keep the file in your Trash.

Video of the Day

Using RM and RMDIR

Type "rm" followed by the name of a file to permanently delete it from your hard drive. File names with a space in them must be "escaped" using a backslash ("\") character, so delete the file "this file.doc" with the command "rm this\ file.doc". You can also type "this" and hit the tab key to auto-fill the rest of the file name. Use "rmdir" followed by a folder name to delete an empty folder. To delete a folder with files in it, type "rm -r" followed by the folder name.

Moving Files to Trash

If you want to change your mind about deleting a file, move it to the Trash with the "mv" command with the syntax "mv [file name] ~/.Trash". The tilde and the period before the word "Trash" are required.

Show Comments