A find command of Centos cooperates with rm to delete files from a day ago

Statement writing: find the corresponding directory  -mtime  + days -name "file name" -exec rm -rf {} \;

 Example 1: Delete all files with "." 10 days ago in the /usr/local/backups directory

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

 

  find: Linux search command, the user finds files with specified conditions

  /usr/local/backups: any directory you want to clean up

  -mtime : Standard statement writing

  +1 0: Find files 10 days ago, where numbers represent 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 files, this can be used flexibly

  -exec: fixed spelling

  rm -rf: Force deletion of files, including directories

  {} \; : Fixed writing, a pair of braces + space + \

 

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324778152&siteId=291194637