I have a command in my makefile for clean:rm -rf */*.o */*.cmo */*.cmi */*.cmx */*.cma */*.cmxa */*.annotNow I would like to write a cleanpartial that removes these files except those in the folder frontend/ and the folder frontend/gen/.Does anyone know how to write this command properly?
Remove certain types of files except in a folder
bash;shell;find;rm
You should use find for this.You can safely test with the following command:find . \( -name frontend -prune \) -o -type f \( -name \*.o -o -name '*.cm[oixa]' -o -name \*.cmxa -o -name \*.annot \) -printOnce you're happy with the list of files that gets printed, run the real command to delete the lot of them:find . \( -name frontend -prune \) -o -type f \( -name \*.o -o -name '*.cm[oixa]' -o -name \*.cmxa -o -name \*.annot \) -exec rm -f {} +