I am using the preprocessor of gcc to remove the comments from a verilog (.v) file (since the comment syntax is same as C/C++). I am using perl and hence used a shell command from my perl script
gcc -E $dest > $commentsrem
try.c:577: unterminated character constant
Redirecting standard error to the null device would silence all error output from the preprocessor. Not generally recommended, as you will not see genuine errors either.
gcc -E $dest > $commentsrem 2> /dev/null
The better way would be to filter known messages from the stderr by use of
grep -v, so you would still see other error messages. For this, you need to redirect stderr to stdout, because piping doesn't work on stderr:
gcc -E $dest 2>&1 > $commentsrem | grep -v "unterminated character constant"
The order of the redirections is important here. If you wrote
> $commentsrem 2>&1, the error messages would end up in
For details on the redirecting, ref. this Q/A.