Terminal Icon

Removing a file or directory

You can remove a file or directory by using the rm command.

To remove a file or directory:

  • To delete a file called myfile1 and its contents, enter:

    rm myfile1
  • To remove a directory and all of its contents, you must include “-r” to recursively delete the directory and all the items it contains.

    To delete an entire directory called myDirectory, enter:

    rm -r myDirectory

You can delete multiple items by including a list of items to be deleted.

For more information on removing files, see the rm man page by entering “man rm” in the Terminal window.


Related Topics

UNIX

Open

man page for rm