Live data from Hacker News

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

news.ycombinator.com

21–30 of 76 posts

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

#23

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.

Most have SSD drives now that trims the space on delete. Not sure how easy it is to mark regions on the SSD for "undelete" when it has been trimmed. In some cases the deleted region of the drive may even be mapped to another place on the memory chip itself to cycle it.

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

#24
post #2

I wish something like this were built into kernel filesystem driver. All deletions automatically go to this specific place in the filesystem.

This would be fun as an experiment to see how quickly it fills up the drive, but probably utterly useless in production. A lot of stuff is creating and deleting files all the time, e.g. logrotate.

It could be fifo and you would still be able to undo damage for some time.

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

#26

Earlier quoted context omitted.

Even simpler: alias del="mv -t ~/.Trash/"

Now let's delete them after roughtly 30 days: alias del="mv -t ~/.Trash/ ; find ~/.Trash/ -mtime +30 -exec rm {} \;"

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`

#27
nilfs2 is my alternative. It's a log-based filesystem that results in continuous checkpoints that can be upgraded to mountable snapshots at any time. Realized you blew away a file you needed? Made large modifications you wish you hadn't? Just find an earlier checkpoint and your good to go.

Backups too. Nothing replaces backups.

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

#28

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.

Check out nilfs, where this is explicit. Every filesystem action results in a checkpoint, and checkpoints are garbage collected only as-needed to maintain free space.
Post reply on HN