Unix command to delete a directory in terminal

Unix command to delete a directory in terminal

To delete a directory in Unix, you can use the rm command with the -r option to delete the directory and all its contents recursively.

For example, to delete the directory mydir and all its contents, you can use the following command:

‮ refer‬to:lautturi.com
rm -r mydir

This will delete the directory mydir and all its subdirectories and files.

Note that the rm command is a powerful and dangerous tool, as it can permanently delete files and directories without prompting for confirmation. To avoid accidental deletions, you can use the -i option to make rm prompt you for confirmation before deleting each file. For example:

rm -ri mydir

This will ask you to confirm whether you want to delete each file and directory within mydir.

Overall, the rm command is a useful tool for deleting directories in Unix, but it should be used with caution to avoid accidental data loss.

Created Time:2017-10-30 14:27:30  Author:lautturi