Linux rm deletes a large number of files, linuxrm

Source: Internet
Author: User

Linux rm deletes a large number of files, linuxrm

When you use rm to delete a large number of files, you may encounter an Argument list too long problem. As shown below

[oracle@DB-Server bdump]$ rm -v epps_q001_*
-bash: /bin/rm: Argument list too long

Check the total number of such files, as shown below. There are 8348 files in total.

[oracle@DB-Server bdump]$ ls -lrt epps_q001_* | wc -l
-bash: /bin/ls: Argument list too long
0
 
[oracle@DB-Server bdump]$ find . -name "epps_q001_*" | wc -l
8438

 

The xargs command can be used to solve this problem. As follows:

[oracle@DB-Server bdump]$ find . -name "epps_q001_*" | xargs rm -r
 

An error occurred while deleting a large number of files in linux.

Two methods:
1) find
Find.-name *-exec rm {}\;

2) Pipelines
Ls-l | awk '{print $9}' | rm

If you want to delete a directory, use the r parameter in the rm command. If you do not need a prompt when deleting the directory, add the f parameter. Use the r and f parameters of rm with caution!

In Linux, how does one completely delete the rm file?

Rm-r + file path;
For example, to delete the 1.txt file in the/home/ftk/apache-tomcat-5.5.20/workrm folder, run the following command:-r/home/ftk/apache-tomcat-5.5.20/work/1.txt.
Hope to help you, hope to adopt it ~

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.