Search code examples
grepdoxygentcsh

Filter Doxygen output with grep


I want to filter the doxygen warnings with grep, to supress the undocumented parameter warning for certain parameters. I am trying this:

doxygen doxycfgfile | grep -v "parameter x"

however this seems to have absolutely no effect on the output. Neither the lines containing parameter x are suppressed nor all other lines. The output appears to be exactly the same.

I am using tcsh.


Solution

  • Presumably this is because the undocumented parameter warning messages are being written to standard error (stderr), rather than standard out (stdout). With the pipe (|) you are only piping stdout to grep's input.

    You could try doing something like

    doxygen doxycfgfile |& grep -v "parameter x"
    

    From the advanced bash scripting guide:

    If |& is used, the standard error of command1 is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |.

    Note, this was added in Bash 4, so for earlier versions you will have you use 2>&1 | in place of |&.

    Alternatively, you could just get rid of the standard error output, using something like

    doxygen doxycfgfile 2>/dev/null
    

    This answer on askubuntu was the source for my answer.