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?
rmin a sandbox? It looks like-fdoes exactly what you want, regardless of the globbing. – JMD Nov 27 '09 at 17:02-foption 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. – LawrenceC Jun 13 '12 at 01:24rm --interactive=neverwhich acts likerm -fexcept it does return an error exit status. see here for more details: https://unix.stackexchange.com/questions/72864/how-to-avoid-the-need-to-issue-y-several-times-when-removing-protected-file/438486#438486 – Lesmana Apr 08 '19 at 07:11