# is the comment character of a
shell. This means that after removing comments from the line the shell
will see the linerm which will
result in an error message as rm expects arguments.The solution to this problem is to use quoting to prevent the shell from removing the comment. Any of the following two line will work fine.
rm '#foo.c#'
rm "#foo.c#"
If you are lucky, the shell will automatically quote the string for
you (e.g. bash will quote a word if you expand it using
TAB).