Live data from Hacker News

Stop Using `rm` in Bash. Use `del`

news.ycombinator.com

1–10 of 76 posts

Stop Using `rm` in Bash. Use `del`

#1
We’ve all had our fair share of accidentally removing files. Instead of

  rm my_file.txt
or

  rm -rf my_folder
we do

  del my_file.txt
or

  del my_folder
where you can define your Bash alias for `del` in ~/.custom_aliases as

  function del() {
      mv $* ~/.Trash
  }
which simply moves your files/folders to the trash such that you can recover them easily later.

What’s your alternative?

Re: Stop Using `rm` in Bash. Use `del`

#3
For Linux users: also look into the trash-cli [1] package, which complies with the FreeDesktop.org trash specification and remembers the original path, etc. so that trash items can be restored even with filename collisions. Then it's

    trash-put my_file.txt
[1] https://github.com/andreafrancia/trash-cli

Re: Stop Using `rm` in Bash. Use `del`

#5
rm is for removing stuff. If you don’t want to remove the file, use mv.

Take care when entering commands, if it’s important that you don’t mess up, spend an extra second. Don’t run around shooting rm -rf as super user.

With great powers comes great responsibility.

Re: Stop Using `rm` in Bash. Use `del`

#10

rm is for removing stuff. If you don’t want to remove the file, use mv. Take care when entering commands, if it’s important that you don’t mess up, spend an extra second. Don’t run around shooting rm -rf as super user. With great powers comes great responsibility.

Would be nice if filesystems were garbage collected, though. I don't see a fundamental reason why rm couldn't be undoable the second after you issue it.
Post reply on HN