Find + rm command combination in CentOS

Source: Internet
Author: User

Find + rm command combination in CentOS
Find + rm, a super-convenient but extremely tragic command combination in centos

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.