Back to LinkedIn posts

LinkedIn post 306

Very good tip! How to revert "rm -rf"? ๐Ÿ”ฅ๐Ÿ˜ฌ

Very good tip! How to revert "rm -rf"? ๐Ÿ”ฅ๐Ÿ˜ฌ

When you delete a folder and the subfolders, how to get all that back? You can't. ๐Ÿฅฒ

๐Ÿ™๐Ÿฝ Thanks to Erick Wendel who shared a great find: safe-rm ๐Ÿคฏ

It is a command that moves the files to the Trash Can instead of deleting them.

To install:
1) npm i -g safe-rm
2) alias rm='safe-rm'
3) or add to the ~/.zshrc file to make it permanent: alias rm='safe-rm'

This will make the command rm execute safe-rm instead so files get moved to the Trash Can instead of irreversibly lost. ๐Ÿคฉ

Later I've found that if you don't want to install safe-rm, you can still create an alias for rm by editing the ~/.zshrc file:
alias rm='rm -i'
That will simply make rm ask you for confirmation before removing any file, giving a last chance to avoid a costly mistake.

Very good tip! How to revert "rm -rf"? ๐Ÿ”ฅ๐Ÿ˜ฌ