Linux Command Learning Summary of the RMDIR command _linux

Source: Internet
Author: User
Tags mkdir

Introduction to Commands:

The rmdir command is used to delete an empty directory and an error occurs if the directory is not empty. After you can use RM to delete a file in a directory, use RmDir to delete the directory. You can also use RM-RF instead of the rmdir command. This is a very simple command.

Command syntax:

rmdir [OPTION] ... DIRECTORY ...

Command parameters:

Parameters

Long parameters

Description

--ignore-fail-on-non-empty

Ignore any errors caused by data files in the directory

-P

--parents

Recursively delete directory

-V

--verbose

Show detailed information about command execution

--help

Show Commands online Help

--version

Display Command version information

Use examples:

1: View Help for the rmdir command

[Root@db-server ~]# rmdir--helpusage:rmdir [OPTION] ... DIRECTORY ... Remove the DIRECTORY (ies), if they are empty. --ignore-fail-on-non-empty Ignore each failure this is solely because a directory is non-empty-p,--parents Remove DIRECT Ory and its ancestors. e.g., ' rmdir-p a/b/c ' is similar to ' rmdir a/b/c A/b '. -V,--verbose output a diagnostic for every directory processed--HELP display it help and exit--version output version Information and exit bugs to <bug-coreutils@gnu.org>.

You can also use the following command to view RmDir Document information

[Root@db-server ~]# Mans RmDir

2: Use RmDir to delete empty directories

If the directory is not empty, an error message appears.

[Root@db-server ~]# ls/root/kerry/file1[root@db-server ~]# rmdir kerryrmdir:kerry:Directory not empty[root@db-server ~ ]# Rm-f/root/kerry/*[root@db-server ~]# rmdir Kerry

3: Show details of command execution

[Root@db-server ~]# mkdir test1 test2 test3[root@db-server ~]# lsanaconda-ks.cfg Desktop install.log install.log.syslog t Est1 test2 test3[root@db-server ~]# rmdir-v, test1 test2 directory, test3rmdir:removing directory, t Est2rmdir:removing directory, Test3

4: Delete the directory recursively, as shown below, first create the directory Kerry, create an empty directory TMP under the Kerry directory, and then empty directory test

[Root@db-server ~]# mkdir-p kerry/tmp/test[root@db-server ~]# Tree kerrykerry '--tmp '--Test 2 directories, 0 files[root @DB-server ~]# rmdir-p kerry/tmp/test

5: Ignore any errors caused by data files in the directory

[Root@db-server ~]# mkdir Kerry [root@db-server ~]# CD Kerry [root@db-server kerry]# touch file1 [Root@db-server Kerry] # CD ... [Root@db-server ~]# rmdir--ignore-fail-on-non-empty kerry/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.