It is necessary to delete the files under this directory according to time,/home/lifeccp/dicom/studies, and clean up the invalid data 20 days ago.
You can use the following command to complete:
Find /home/lifeccp/dicom/studies-mtime +"* *"rm -rf {} \;
This is deleted based on time.
The following is a brief explanation of the shell command:
Find/home/lifeccp/dicom/studies-mtime +21-name "* *"-exec RM-RF {} \;
- /home/lifeccp/dicom/studies: Prepare any directory to be cleaned
- -mtime: Standard statement notation
- +10: Find the file 10 days ago, where the number represents the number of days, +30 means to find the file 30 days ago
- "*. *": The type of data you want to find, "*.jpg" means looking for all files with the extension jpg, "*" means finding all files
- -exec: Fixed notation
- RM-RF: Forcibly deleting files, including directories
- {} \; : fixed notation, pair of curly braces + space +/+;
Of course, according to the file name, according to the size, according to other different conditions to filter the deletion, or modify, etc., you can consider the sort command combined with. Because the time is limited, here is not to repeat, back to use when, I slowly add.
Linux Bulk Delete Files by time (delete n days ago file)