Ignoring the first line of stderr and keeping stdout intact

会有一股神秘感。 提交于 2019-12-13 21:03:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!