trails
asked on
tcsh redirection
How can I redirect stderr to /dev/null, and keep stdout going to stdout? Something like:
(foo > stdout) >& /dev/null
But that doesn't work, obviously. Easy in bash, but I can't figure it out in tcsh.
thanks,
trails
(foo > stdout) >& /dev/null
But that doesn't work, obviously. Easy in bash, but I can't figure it out in tcsh.
thanks,
trails
"bash -c 'foo 2>/dev/null'" isn't acceptable?
ASKER
Yeah, it's okay, I guess I would just like to know if it's possible in tcsh. But I don't think it is. You can redirect to /dev/tty, but that's a hack that doesn't work very well at all.
Thanks for the comment,
trails
Thanks for the comment,
trails
proposing the same as an answer:
"bash -c 'foo 2>/dev/null'"
"bash -c 'foo 2>/dev/null'"
it can be done in tcsh too, without using bash
ASKER
I'm sorry, I'm going to have to reject that answer on principle. First: I already knew how to do it in bash, as I stated in my original question. Second: someone says it's possible, so if there's an answer, that deserves the points.
trails
trails
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the proposed answer redirects output to /dev/tty, so stdout doesn't keep going to stdout (as the question stated).
mliberi, what do think is the difference between stdout and /dev/tty (in this special case)?
BTW, it does not redirect to /dev/tty, more correctly to the shells tty; see man tty
BTW, it does not redirect to /dev/tty, more correctly to the shells tty; see man tty
There is a big difference between tty and stdout.
Suppose your command has been placed in a script, let's say 'xxx'
By calling the script with the syntax "xxx >myfile" I would expect that the output of the script to be written to "myfile". With the command you gave the output would be placed on the screen.
from "tty" man page:
> tty Command
>
> Purpose
>
> Writes to standard output the full path name of your terminal.
Do you still think that stdout and `tty` to be the same thing?
Suppose your command has been placed in a script, let's say 'xxx'
By calling the script with the syntax "xxx >myfile" I would expect that the output of the script to be written to "myfile". With the command you gave the output would be placed on the screen.
from "tty" man page:
> tty Command
>
> Purpose
>
> Writes to standard output the full path name of your terminal.
Do you still think that stdout and `tty` to be the same thing?
well I agree for the special case: script-file :-)
(you remember my comment: this special case?)
If you would do in a csh script, you would probably to do it like:
(your_command > tmp_file)>&/dev/null
cat tmp_file
As I, said in my answer: redirecting stdout without stderr is not implemented in
csh/tcsh.
So trails no knows how to do it interactiv and in a script ;-)
(you remember my comment: this special case?)
If you would do in a csh script, you would probably to do it like:
(your_command > tmp_file)>&/dev/null
cat tmp_file
As I, said in my answer: redirecting stdout without stderr is not implemented in
csh/tcsh.
So trails no knows how to do it interactiv and in a script ;-)