Bash script to clear files not matching a given extension
My real concerns with the script are:


cleantex path/to/file.tex will not delete files in that path, but in the current directory.
you should check the actual .tex file exists before you delete all the things around it.
the brace-expansion is unnecessarily complicated...... especially when combined with the extended glob !(*tex). I would manually resolve the brace-expansion so that there is only one complicated operation on that line.
I would use actual glob-expansion and only delete existing files.... and not use the -f option on rm (which does more than just suppress the error message if files do not exist....)