To remove directories safely, you can use the rm command with the -i option, which prompts you for confirmation before each deletion. Here’s how to do it:
-
For an empty directory:
Usermdirfor empty directories:rmdir -i directory-name -
For non-empty directories:
Usermwith the-r(recursive) and-i(interactive) options:rm -ri directory-name
This way, you will be asked to confirm each file and directory deletion, helping to prevent accidental loss of important data. Always double-check the directory name before confirming the deletion.
