Reputation: 423
I'm trying to write the result of:
bzip2 --version
to a file. However, nothing seems to be able to "see" the version info that's printed onto the screen. For example:
bzip2 --version > test.txt
creates an empty file and
bzip2 --version | grep Version
prints the entire paragraph of text, whereas
gcc --version | grep gcc
prints only the line with "gcc" on it.
What is bzip2's --version flag doing differently, and how do I capture it's output?
Upvotes: 1
Views: 153
Reputation: 311163
The output of bzip --version
is written to stderr, not stdout, so it has to be redirected with 2>
instead of a plain old >
:
mureinik@computer ~ $ bzip2 --version 2> test.txt
Upvotes: 2