I'm not sure if you are trying to hide STDERR or redirect it to STDOUT.
To redirect STDOUT to a file:
pkg_add emacs-23.4,2.tbz > stdout.log
To redirect STDOUT and STDERR to a file:
pkg_add emacs-23.4,2.tbz > & stdxxx.log
To redirect STDOUT to a file and hide STDERR:
( pkg_add emacs-23.4,2.tbz > stdout.log ) > & /dev/null
To redirect STDOUT to console and hide STDERR:
( pkg_add emacs-23.4,2.tbz > /dev/tty ) > & /dev/null
To redirect STDOUT to console and STDERR to a file:
( pkg_add emacs-23.4,2.tbz > /dev/tty ) > & stderr.log
To redirect STDOUT to a file and STDERR to a file:
( pkg_add emacs-23.4,2.tbz > stdout.log ) > & stderr.log
EDIT:
The reason why this works is that the action in the ()'s happens first; Ergo, if we've redirected STDOUT, then it will no longer be available outside of the ()'s. This leaves us with just STDERR, and then we can redirect that as desired.
sh
. – gadgetmo Apr 04 '12 at 17:45pkg_add
on FreeBSD, so I'm assuming this is for the root user (/bin/csh is the default for root on FreeBSD). In this case you should not change the shell to /usr/local/bin/bash. /bin/sh is acceptable. You could also just switch to another shell after logging in as root. – James O'Gorman Apr 06 '12 at 23:21