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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.