-
How to remove directory in linux (rmdir)linux 2023. 2. 20. 16:53
In Linux, rmdir is a command-line utility used to remove empty directories. Here is a table of common options for the rmdir command in Linux:
OptionDescription
-p Remove the parent directories if they are empty -v Print the name of each directory as it is being removed -ignore-fail-on-non-empty Ignore directories that are not empty and do not remove them And here are some simple examples of how to use the rmdir command:
- To remove an empty directory, use the following command:
rmdir directoryname- To remove a directory and its parent directories if they are empty, use the following command:
rmdir -p parentdirectory/directoryname- To print the name of each directory as it is being removed, use the following command:
rmdir -v directoryname- To ignore directories that are not empty and do not remove them, use the following command:
rmdir --ignore-fail-on-non-empty directorynameNote that the rmdir command will only remove empty directories. If a directory contains files or other directories, you need to use the rm command with the -r option to recursively remove the directory and its contents.
'linux' 카테고리의 다른 글
File addressing in Linux (0) 2023.02.20 How to display file contents in linux (cat) (0) 2023.02.20 How to create a file in linux (touch) (0) 2023.02.20 How to move file or directory in linux (mv) (0) 2023.02.20 How to copy file or directory in linux (cp) (0) 2023.02.20