Linux Common Commands Summary--rmdir

Source: Internet
Author: User

1. Function: Delete empty directory.


2. Usage:rmdir parameter Path


3. Parameters:

-P: Recursively delete empty directories, ' rmdir-p a/b/c ' is equivalent to executing a rmdir a/b/c A/b '


4. Example

[Email protected] home]# tree test

Test

├──test_1

│├──test_1.txt

│└──test_2

│├──test_2.txt

│└──test_3

├──test_1.txt

└──test_4

└──test_5

Example 1:test_1 file, can not be deleted through the rmdir command, Test_5, there is no file under the rmdir command to delete;

[Email protected] home]# rmdir test/test_4/test_5/

[Email protected] home]# rmdir test/test_1

RmDir: Delete "test/test_1" failed: Directory not empty

[Email protected] home]# tree test

Test

├──test_1

│├──test_1.txt

│└──test_2

│├──test_2.txt

│└──test_3

├──test_1.txt

└──test_4


Example 2: Delete Test_4, Test_5, test_6 three folders at the same time

[Email protected] test]# mkdir-p test/test_4/test_5/test_6

[Email protected] test]# tree

.

├──test

│└──test_4

│└──test_5

│└──test_6

├──test_1

│├──test_1.txt

│└──test_2

│├──test_2.txt

│└──test_3

└──test_1.txt


[Email protected] test]# rmdir-p test/test_4/test_5/test_6/

[Email protected] test]# tree

.

├──test_1

│├──test_1.txt

│└──test_2

│├──test_2.txt

│└──test_3

└──test_1.txt


A few empty folders under the test folder have been deleted.



This article is from the "three countries Cold jokes" blog, please be sure to keep this source http://hwj91.blog.51cto.com/9763975/1773141

Linux Common Commands Summary--rmdir

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.