That is not a good idea to be doing it this way,
see :
The -r option ,... recursively
The -f option -f, --force (force-remove all files without prompting you)
followed with / ,....logic should tell you what could happen.
but in case it does not :
/ – Tells rm to start at the root directory, which contains all the files on your computer and all mounted media devices, including remote file shares and removable drives.
Some times it is hard to tell if this "bester69" is serious or joking, I think maybe he is joking in this case,...
by bester69 » I'd like you to help me with an easy script to wrap "rm -rf" when i exec this command to prevent to erase some critical folders.
"to prevent to erase some critical folders",.... this command can remove everything,and
will, and not even give a warning or ask you Yes or no,...
Look at the manual on 'rm'
-f, --force
ignore nonexistent files, never prompt
-r, -R, --recursive
remove directories and their contents recursively
-v, --verbose
explain what is being done
To prevent removing critical files, you would want to use:
Code: Select all
rm -r -v /this/orthat/directory/andfiles.*
Or some thing a long that line, would be safe to use, and
it would prompt you, verbally, just to make sure you really
want to remove the directory and the files, and subdirectories in it.
That way, if there are any "critical files", or directories that happen to
be in the path, you still have a chance to cancel the operation.
Yes I do realize /home/joe/thisfile, in theory should keep it from
starting at / ,.... in theory, it would only remove the files and sub directories that the "path" points to,
"thisfile",..... however a tiny typo, or space, where you shouldn't have had
one, and combined with the fact that it is forced, with no warnings,...How do you plan to test the "script" ? Hopefully on a VM,... because if there is a mistake, it could just remove everything.
edbarx wrote:
If you don't want to accidentally shoot yourself in the head, don't play Russian Roulette.
Is the perfect analogy. ( I think "analogy" is the right word" )
Any way that is about what it boils down to.