I just lost some data in folder A which was inside folder B after doing rm -rf B. Before I could realize what have I done, it was all over. Now a lesson is learnt, I wish to make some of my folder idiot-proof to avoid a next time when I do something similar and want to kill myself. One way I can think of is to write a bash function and alias it to rm. This function will look into each sub-folder for a hidden file such as .dontdelete. When found, it would ask if I really want to continue. I can not make is write-protected since there is a process which constantly write to this folder. Is there any better way to do it?
Making a directory protected from 'rm -rf'
permissions;directory;rm
In researching your question I came across this technique which might help you in the future. You can apparently touch a file in the directory like so:touch -- -iNow when you run the command rm -fr * in a directory where the -i is present you'll be presented with the interactive prompt from rm.$ lsfile1  file2  file3  file4  file5  -i$ rm -fr *rm: remove regular empty file `file1'? nrm: remove regular empty file `file2'? nrm: remove regular empty file `file3'? nrm: remove regular empty file `file4'? nrm: remove regular empty file `file5'? nThe same thing can be achieved by just leaving an alias in place for rm to always do rm -i. This can get annoying. So often what I've seen done is to have this alias in place, and then to disable it when you really want to delete without being prompted.alias rm='rm -i'Now in directories you'll be greeted like this:$ lsfile1  file2  file3  file4  file5$ rm -r *rm: remove regular empty file `file1'?To override the alias:$ \rm -r *This still doesn't stop a rm -fr however. But it does provide you with some protection.ReferencesHow to prevent yourself from accidentally deleting files in Unix/Linux