Redirect not working correctly, 2> /dev/null becomes 2 > /dev/null and stderr doesn't get redirected
In a comment, you say "A minor note, this is csh". That's not a minor note, that's the cause of the problem. xterm
is just a terminal emulator, not a shell; all it does is set up a window that provides textual input and output. csh
(or bash
, or ...) is the shell, the program that interprets the commands you type.
csh has different syntax for redirection, and doesn't let you redirect just stderr. command > file
redirects stdout; command >& file
redirects both stdout and stderr.
You say the system doesn't have bash, but it does have ksh. I suggest just using ksh; it will be a lot more familiar to you. Both bash and ksh are derived from the old Bourne shell.
All (?) Unix-like systems will have a Bourne-like shell installed as /bin/sh
. Even if you're using csh (or tcsh?) as your interactive shell, you can still invoke sh, even in a one-liner. For example:
sh -c 'command 2>/dev/null'
will invoke sh
, which in turn will invoke command
and redirect just its stderr to /dev/null
.
The purpose of an interactive shell is (mostly) to let you use other commands that are available on the system. sh
, or any shell, can be used as just another command.