How to delete a large number of files in Linux

Source: Internet
Author: User

How to delete a large number of files in Linux

How to delete a large number of files

To delete a large number of files in Linux, You need to delete 100,000 files. This is the log written by the previous program, which is growing fast and useless. At this time, the common delete command rm-fr * is not easy to use, because it takes too long to wait. Therefore, we must take some extraordinary measures. We can use the -- delete-before parameter of rsync to quickly delete a large number of files.

1) Create an empty folder:

Mkdir/tmp/test

2) use rsync to delete the target directory:

Rsync -- delete-before-a-H-v -- progress -- stats/tmp/test/log/

In this way, the log directory to be deleted will be cleared and the deletion speed will be very fast. Rsync actually uses the replacement principle, and processing 100,000 files is also deleted in seconds.

Option description:

-- Delete-before: the receiver is deleted before transmission.

-- Progress displays the transmission process during transmission

-- A archive mode: Transfers files recursively and maintains all file attributes.

-- H: Keep a hard-connected File

-- V detailed output mode

-- Stats indicates the transmission status of some files.

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.