To recursively delete a directory and all of its contents in Unix-like systems, you can use the rm
command with the -r
(or --recursive
) option.
Here’s an example of how to use the rm
command to delete a directory called “example_dir” and all of its contents:
rm -r example_dir
The -r
option tells rm
to recursively remove the contents of the specified directory, including any subdirectories and files.
Note that the rm
command is a powerful tool and can permanently delete files, so use it with caution. If you’re unsure about what you’re deleting, you can add the -i
(or --interactive
) option to rm
to prompt you for confirmation before deleting each file:
rm -ri example_dir
This will prompt you for confirmation before deleting each file, allowing you to verify what you’re deleting before it’s permanently removed.