News for hackers. Stuff that matters.
Re:Stop Using `rm` in Bash. Use `del` by dan-robertson on Sunday March 17, 2019 @09:16AM (#19413847)
Even simpler:

  alias del="mv -t ~/.Trash/"
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:

  alias del="mv -t ~/.Trash/ ; find ~/.Trash/ -mtime +30 -exec rm {} \;"
Re:Stop Using `rm` in Bash. Use `del` by majewsky on Sunday March 17, 2019 @10:44AM (#19414265)
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 :)

Re:Stop Using `rm` in Bash. Use `del` by wumms on Sunday March 17, 2019 @01:08PM (#19415009)
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!

Re:Stop Using `rm` in Bash. Use `del` by elcomet on Sunday March 17, 2019 @09:44AM (#19413982)
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.
Re:Stop Using `rm` in Bash. Use `del` by floatingatoll on Sunday March 17, 2019 @10:26AM (#19414167)
This fails on non-GNU mv(1) binaries such as macOS.