A find command in Linux with RM deletes the file method a day ago _linux

Source: Internet
Author: User

Statement writing: Find corresponding directory-mtime + days-name "filename"-exec rm-rf {} \;

Example 1: The/usr/local/backups directory is all 10 days ago with "." The file deletion

Find/usr/local/backups-mtime +10-name "*.*"-exec rm-rf {} \;

Find:linux Lookup command, the user finds the file for the specified condition

/usr/local/backups: Any directory that you want to clean

-mtime: The standard sentence formulation

+10: Find 10 days before the file, where the number of days to represent, +30 to find 30 days before the file

"*.*": the type of data you want to find, "*.jpg" means to find all the files with the extension jpg, "*" means to find all the files, this is flexible to use, extrapolate

-exec: Fixed wording

RM-RF: Force delete files, including directories

{} \; : fixed wording, a pair of curly braces + space +\

Find $1-name "*.html"-mtime +1-print0 |xargs-0 rm-v

Above this Linux a Find command with RM delete a day before the file method is small series to share all the content, hope to give you a reference, also hope that we support cloud habitat community.

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.