Sample Header Ad - 728x90

How to grep standard error stream (stderr)?

169 votes
12 answers
164889 views
I am using ffmpeg to get the meta info of an audio clip. But I am unable to grep it. $ ffmpeg -i 01-Daemon.mp3 |grep -i Duration FFmpeg version SVN-r15261, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i386 --extra-cflags=-O2 ... I checked, this ffmpeg output is directed to stderr. $ ffmpeg -i 01-Daemon.mp3 2> /dev/null So I think that grep is unable to read error stream to catch matching lines. How can we enable grep to read error stream? Using [nixCraft](http://www.cyberciti.biz/faq/redirecting-stderr-to-stdout/) link, I redirected standard error stream to standard output stream, then grep worked. $ ffmpeg -i 01-Daemon.mp3 2>&1 | grep -i Duration Duration: 01:15:12.33, start: 0.000000, bitrate: 64 kb/s But what if we do not want to redirect stderr to stdout?
Asked by Andrew-Dufresne (6043 rep)
Oct 26, 2010, 01:42 AM
Last activity: May 13, 2025, 07:07 PM