A script to clean files in the trashcan that have been kept for more than a specified number of days.
|
|
1 年之前 | |
|---|---|---|
| .github | 1 年之前 | |
| scripts | 1 年之前 | |
| .gitignore | 1 年之前 | |
| CONTRIBUTING.md | 1 年之前 | |
| LICENSE | 1 年之前 | |
| README.en.md | 1 年之前 | |
| README.md | 1 年之前 | |
| clean_trash.sh | 1 年之前 |
简体中文 | English
A script to clean files in the trash that have been kept for more than a specified number of days.
Trash Cleaner Tool
Usage: ./clean_trash.sh [-h] [-v] <days to keep>
Options:
-h Show help message
-v Verbose output mode
Examples:
./clean_trash.sh 30 # Clean trash files older than 30 days
./clean_trash.sh -v 7 # Verbose mode to clean files older than 7 days
When you "delete" a file in a Linux desktop environment, it moves the file to a special "trash" directory, which is usually ~/.local/share/Trash/.
The trash directory typically contains three subdirectories:
files/: Stores the deleted files themselves. For example: question.png.info/: Stores metadata related to the deleted files (such as the original path, deletion timestamp, etc.). For example:
[Trash Info]
Path=/home/user/question.png
DeletionDate=2025-08-13T19:47:35
expunged/: Temporarily stores files that are to be permanently deleted.
expunged Folderfiles/ and info/ directories.files/ directory to the ~/.local/share/Trash/expunged/ directory (because moving files is fast).info/ directory; and slowly physically deletes the corresponding files in the expunged/ directory (deleting a large number of files takes time, and doing it too quickly may slow down the entire computer).