问题
mongodump
prints a single debug message to stderr every time it is run, which is causing some unintended side effects. How do I ignore only the first line of stderr and keep everything else intact?
I'm piping stdout to a file, so I can't combine stderr and stdout.
回答1:
Using a process substitution, and piping stdout into rev
to see that stderr is unaffected
{ echo stderr1 >&2; echo stdout1; echo stderr2 >&2; } 2> >(sed 1d >&2) | rev
1tuodts
stderr2
来源:https://stackoverflow.com/questions/19759660/ignoring-the-first-line-of-stderr-and-keeping-stdout-intact