error output redirection
George Davidovich
freebsd at optimis.net
Sun Oct 11 22:46:17 UTC 2009
On Sun, Oct 11, 2009 at 11:36:52PM +0200, Stefan Miklosovic wrote:
> if error output of some program appear on screen, it is possible to
> print it also to some file simultaneously?
Depends on the program, but generally, yes.
http://en.wikipedia.org/wiki/Standard_streams
http://en.wikipedia.org/wiki/Redirection_(computing)
> e.g if I "cat" file which do not exist, error is on screen, I want to
> add that error to some file (errors.txt)
Replacing 'cat file_that_does_not_exist' with 'badcommand'
# redirect STDERR to a file
badcommand 2> errors.txt
# append STDERR to a file
badcommand 2>> errors.txt
# fun with file descriptors to have it both ways
badcommand 3>&1 1>&2 2>&3 | tee errors.txt
--
George
More information about the freebsd-questions
mailing list