mrd
Remove empty directories
SYNOPSIS
mrd DIRECTORY...
PARAMETERS
DIRECTORY
The name of the directory to remove. Multiple directory names can be specified.
--ignore-fail-on-non-empty
Suppress the error message when attempting to remove a non-empty directory.
--parents
Remove DIRECTORY and its parents, all of which must be empty.
-p
Same as --parents. Remove DIRECTORY and its parents, all of which must be empty.
-v
Same as --verbose. Output a diagnostic for every directory processed.
--verbose
Output a diagnostic for every directory processed.
--help
Display help information and exit.
--version
Output version information and exit.
DESCRIPTION
The mrd command is an alias for the rmdir command in Linux. It is used to remove empty directories. Unlike rm -r, which can recursively delete directories containing files and subdirectories, mrd specifically targets empty directories and will fail if the directory is not empty. This makes it a safer option when you only want to remove directories that you are sure are empty and avoid accidental data loss. Use caution with any remove commands.
Essentially, mrd is a shorthand way to invoke rmdir. It offers no additional functionality or options beyond those provided by rmdir. If you're accustomed to using other operating systems where 'md' might stand for 'make directory,' it's important to remember that in Linux, mrd means 'remove directory,' mirroring the functionality of rmdir.
While convenient, relying solely on mrd or rmdir for directory removal might be inefficient if you frequently need to delete non-empty directories. In such cases, rm -r remains the standard tool, albeit with the increased risk of unintended data deletion. Therefore, always double-check the contents of a directory before using any removal command.
CAVEATS
mrd will only remove empty directories. If the specified directory contains any files or subdirectories, the command will fail and report an error. It is crucial to ensure the directory is empty before using mrd.
EQUIVALENCE TO RMDIR
mrd is typically implemented as an alias to rmdir. You can verify this on most systems by typing 'alias mrd' in the terminal, which will show the alias definition.
SAFETY
While rm -r can remove files/directories regardless of content, mrd/rmdir fails on non-empty directories, which can protect from errors, but also may cause issues in automated scripts.