man page of
rm in GNU coreutils 8.12.197-032bb describes the
--force option as "ignore nonexistent files, never prompt". Without this option, it will remove any existing files, never prompt, and return a non-zero exit code if any of the specified files did not exist. I'd like to preserve the files if any of the specified files do not exist. What is the easiest way to do this?
The use case is safety: If I'm trying to remove a file which doesn't exist, it could be because there's an invalid expectation (or plain bug) in the command. For example the famous
rm -rf /usr /lib/nvidia-current/xorg/xorg could have been averted in many ways, one of them being such an option (obviously unless the user by some incredible coincidence had a
/lib/nvidia-current/xorg/xorg directory), and another being to Use More Quotes™. However, quotes aren't always enough. For example, consider
ssh host '/bin/rm some paths; /bin/bash foo.sh' - If I had forgotten the semicolon or inserted pretty much any other symbol like colon or comma, it would have tried to remove