I had a mini scare a few weeks ago when I was setting up my new Macbook. I had figured out all the weird configurations I had made on my old one to make developing more efficient for myself and was just about ready to dive back into coding.
I was porting over one final script that I kept to clean
find ~/ -name '*.pyc' -delete
I accidentally excluded the “-” and ended up with
find ~/ name '*.pyc' -delete
And yep, you guessed it; I wiped out my home directory… Thankfully this was on my new Macbook so the damage was limited, but just thinking of what would have happened if I had done it on my other laptop terrifies me.
It also made me reevaluate using
rm. I’ve heard of people aliasing
rm so that it moves the file/directory to the trash can but I’ve also heard that this can cause people to become desensitizes and lead to catastrophes on a production server where your configuration may be different.
For now, I’ve installed rmtrash and added an alias to force this new habit.
alias rm='echo rm is disabled. use rmtrash! didnt remove: '
I dodged a bullet this time but I was also reminded that backing up frequently is always important too 🙂