4 ms·
Now let's delete them after roughtly 30 days: alias del="mv -t ~/.Trash/ ; find ~/.Trash/ -mtime +30 -exec rm {} \;"
by chipironcin 8y ago
Now let's delete them after roughtly 30 days:
alias del="mv -t ~/.Trash/ ; find ~/.Trash/ -mtime +30 -exec rm {} \;"
- elcomet 8y agoThis is not fine, as deleting a small file can be very long if there's a large file to be deleted in the trash.
- ad_hominem 8y agoYeah running the delete in the user's crontab (i.e. in the background and on a schedule) would be a better option IMO.
- floatingatoll 8y agoThis fails on directories, as the -r switch was not included: mkdir foo; del foo and including it will spawn file not found errors for the contents of the foo directory, if any. EDIT: See also neighbor comment about appending filenames!
- majewsky 8y agoThis does not work. The arguments to `del` get appended at the end, after `find`. You want this: del() { mv "$@" ~/.Trash/ && find ~/.Trash -mtime +30 -delete } I also replaced the unnecessary exec by find's builtin -delete
- futureastronaut 8y agoThank you, it's painful to see people providing replacements for critical commands like `rm` without understanding basic shell features like aliases. And just a reminder everybody please don't run random scripts you find on the internet. P.S. you need a semicolon before the close brace :)
- wumms 8y agoCorrect me if I'm wrong, but wouldn't that instantly delete all moved files which are older than 30 days since mv keeps the mtime?
- floatingatoll 8y agoYou’re not wrong :)