tips to avoid rm mistakes
Hey experts,
I'm looking for a little input on dealing with any Code:
rm filename Code:
rm -r filename Thanks! P.S. Maybe even some tips on how to deal with a mistake that may have already happened as well. P.P.S. "Don't be stupid, and think before you hit Enter" Does not count as a tip, although it is very good advice. :D |
put alias rm='rm -i' in your .profile
This forces you to confirm each delete. |
above and don't ever use the
-f option. |
well redhat aliases the rm command to use rm -i which will prompt you if you really want to delete a file. just be careful with the -f flag as that will just delete anything without prompting you. also be careful with your spelling when deleting files whose filepaths start with "/". don't mistakenly put spaces in those kind of file paths. also be careful with the wildcard character, "*".
|
Nobody uses the technique of keeping a "trash" directory. How writing a script that puts it into this directory, and then another script that deletes all files that are over 7 days old?
I once read a forum discussion on the repercussions of changing the rm command, and this is something that would need to be kept in mind. Those tips are very useful, but I'm looking for something to protect me a little more. For instance, if I have to put a "yes" in every time I try to remove a file, then that will again be part of my regular routine. I make mistakes often, or make multiple files for backup, thus removing is a vital command in my library. If I'm just being difficult here, then you should tell me. I was just wondering if there is any special approach that some of you gurus use. |
you're being difficult. :p
really, though, if you're prompted if you want to delete a file, you shouldn't be giving it a cursory gloss over. you really need to think if the file you're going to delete is going to break something. in the gui, that's what the trash icon is for. so you can reverse a "delete" if you change your mind. in the shell that's what the -i is for. only really delete a file if you're pretty sure it's not a necessary file. |
All times are GMT -5. The time now is 02:06 PM. |