I'm writing a makefile that will clean up some useless files at the end of the compilation. If a target has already been made, it will of course skip that target and the useless file may not be there. So if I do this:
rm lexer.ml interpparse.ml interpparse.mli
I may get errors because one of the files doesn't exist. Is there any way to tell rm
to ignore these files?
In reading the man page, I see the following option:
-f Attempt to remove the files without prompting for confirma-
tion, regardless of the file's permissions. If the file does
not exist, do not display a diagnostic message or modify the
exit status to reflect an error. The -f option overrides any
previous -i options.
That sounds like almost what I want, but I'm not really sure about the permissions part. Is there a way to do this?
rm
in a sandbox? It looks like-f
does exactly what you want, regardless of the globbing.-f
option still try to delete it. It will fail. It won't tell you it failed. Useful if the filename is a variable or a glob.rm --interactive=never
which acts likerm -f
except it does return an error exit status. see here for more details: unix.stackexchange.com/questions/72864/…