I have a command cmd
that I want to use in a zsh script in the form:
cmd -opt val > info.txt
but I want to redirect stderr from that one line to /dev/null
.
Evidently the following does not work:
cmd -opt val > info.txt > /dev/null
How to do it?
Added: Note that I do not want any regular output written to the terminal; all regular output should be written into the specified file info.txt
.
>
and 2>
are independent and can appear in the same command.
cmd -opt val > info.txt 2> /dev/null
Standard output is redirected to info.txt
, and standard error is redirected to /dev/null
.