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:
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.