Skip to content

rm -rf woes

Featured Replies

Well as you all know a little knowledge is dangerous, especially when it comes to command line rm commands with -rf ;)

Yesterday I managed to delete 16 hours worth of work by trying to clean up mac ._ files. I meant to type:

rm -rf ._*

I accidentally typed

rm -rf ._ *

This is the second time I've made a mistake of this nature. You'd think I'd triple check what I'd typed before I hit enter but alas, I can't get out of the habit of typing a command hitting enter immediately :D

Has anyone ever had any success with making rm an alias of mv? I'm thinking of simulating the recycle bin on windows on the linux box for my user. Here's what someone suggested:

alias rm='mv --target-directory ~/.Trash'

Anyone got anything else to suggest for making rm (including when passed the parameter -rf) instead just move the stuff to a trash area (that will be cleared by a cron job every 24 hours)?

fail.jpg

You know you could always try not putting the f on ;)

Not sure what else to say as I'm guessing just like BSD the mac doesn't catch command line deletes in it's trash can, and so unless you fancy hacking the file system back into shape manually you won't be seeing the files again.

I'd be careful about aliasing rm because you might find that some things depend on the specific RM output.

Perhaps create a del alias to move it or alias rm to rm -i. so forcing confirmation.

I may have zero knowledge with the command line, but couldn't you create a script file that calls the rm command (which you've checked 3 times beforehand) and then if you mistype the name when running it then it'll just tell you there's no such file? No harm, no foul? You could even then call a cron job on the script?

I realise that doesn't help with the actual question at all, so sorry :)

  • Author

The thing is my command deleted a non-existent file ._, and then * (everything) :D

If you ask windows to give you the gun so you can shoot yourself in the foot it will ask you are you sure you want the gun, are you sure you want it loaded, are you really sure you want it, are you sure you want to point it at your foor, are you sure you want to pull the trigger and then it may (or may not) let you do it.

If you ask Unix to give you the gun so you can shoot yourself in the foot, it checks you have permission to do that then says sure boss you know best and hands over the loaded gun.

  • Author

Additionally Windows gives you the option of going back in time and pulling the bullet out of your foot, putting it back in the gun and clearing up the resulting mess :D

Additionally Windows gives you the option of going back in time and pulling the bullet out of your foot, putting it back in the gun and clearing up the resulting mess :D

Not when you're in the habit of shift-deleting or using the console.

Does this warrant one of these?:

epic_fail.jpg

  • Author

It warrants about a hundred of those - but thankfully my boss was understanding and not at all annoyed (not to my face, anyway :D)

-side note : how about using the "truncate table" command without understanding that there's no rollback?

I've done it years and years back - binned off 4 years worth of data. thankfully not done it since :D

(that was pre 10g days...)

  • Author

:D

Once I was really clever (in my mind) and used DELETE FROM commands instead of truncate - all encapsulated in a transaction.. then I realised that the data storage mode didn't support transactions

DOH.

Live and Learn!

I once did 'chmod -R 777 /' as root on my server at home, by the time i realised it was fuct :(

Live and Learn!

I once did 'chmod -R 777 /' as root on my server at home, by the time i realised it was fuct :(

Full permissions to the world + dog.... Ooops

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Important Information

Welcome to BRISKODA. Please note the following important links Terms of Use. We have a comprehensive Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.