Re:Stop Using `rm` in Bash. Use `del`
by chipironcin on Sunday March 17, 2019 @09:25AM
(#19413890)
Now let's delete them after roughtly 30 days:
[ Parent
| on HN ]
This 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
Re:Stop Using `rm` in Bash. Use `del`
by futureastronaut on Sunday March 17, 2019 @01:33PM
(#19415156)
Thank 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 :)
Correct 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?
Re:Stop Using `rm` in Bash. Use `del`
by floatingatoll on Sunday March 17, 2019 @01:49PM
(#19415253)
You’re not wrong :)
Re:Stop Using `rm` in Bash. Use `del`
by floatingatoll on Sunday March 17, 2019 @10:25AM
(#19414159)
This 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!
This is not fine, as deleting a small file can be very long if there's a large file to be deleted in the trash.
Re:Stop Using `rm` in Bash. Use `del`
by ad_hominem on Sunday March 17, 2019 @09:57AM
(#19414034)
Yeah running the delete in the user's crontab (i.e. in the background and on a schedule) would be a better option IMO.