user2211678
user2211678

Reputation: 679

redirect error message to file - shell

I am trying to redirect and view all my error messages from a compile to error.txt According to my book it can be done in this way.

$CC error.cpp > error&1 | more

but however it only creates a blank file but did not store the error messages. what have I done wrong?

p.s i did purposely make my server.cpp can't compile so that it will display some error message

Upvotes: 0

Views: 55

Answers (1)

rjv
rjv

Reputation: 6766

The error is printed to stderr and not stdout

Try

$CC error.cpp 2> error

File descriptor 0 represents stdin
File descriptor 1 represents stdout
File descriptor 2 represents stderr

Upvotes: 2

Related Questions