A find command for Linux with RM deletes files from a day ago

Source: Internet
Author: User

Sentence notation:

Find corresponding directory-mtime + days-name "file name"-exec rm-rf {} \;

Example 1: Place all 10 days before the/usr/local/backups directory with "." The file deletion

Find/usr/local/backups-mtime +10-name "* *"-exec RM-RF {} \;

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

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

  -mtime: Standard statement notation

  +10: Find files 10 days ago, where the number represents the number of days, +30 means to find files 30 days ago

"* *": The type of data you want to find, "*.jpg" means to find all files with the extension jpg, "*" means to find all the files, this can be used flexibly, extrapolate

-exec: Fixed notation

RM-RF: Forcibly deleting files, including directories

{} \; : fixed notation, pair of curly braces + spaces +\

Example 2: Delete all 5-day files in the/var/spool/clientmqueue directory

find/var/spool/clientmqueue/-type f-exec rm-rf {} \;

A find command for Linux with RM deletes files from a day ago

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.