Find + rm command combination in CentOS

Source: Internet
Author: User
In centos, a super-convenient, but extremely tragic command combination, find + rm, believe that friends who have made mistakes can see this command in their hearts, query and delete files based on a certain condition. Example: 1. in linux, find and delete the file a year ago. how can I write a command? # Find/-ctime in centos, a super-convenient but extremely tragic command combination find + rm

I believe that my friends who have made mistakes can see this command in their hearts ......

The find + rm combination queries files based on certain conditions and deletes them.

Example:

1. in linux, find and delete the file a year ago. how can I write a command?

# Find/-ctime + 365-exec rm-rf {}\;

Remember:
The first/represents the root directory. do not write this. write the directory you need to find. Remember, I am here for convenience.
It must be followed by a; No. otherwise it won't work. this is the end of the syntax.

2. in linux, find and delete all php files under a file. how can I write a command?

# Find./-type f-name "*. php"-exec rm-f {}\;

A very useful command combination, but you need to use it carefully. don't regret it for life!

 


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.