[英]Redirect only stderr to /dev/null while redirecting stdout to a file (zsh)
我有一個命令cmd
我想在 zsh 腳本中使用,格式如下:
cmd -opt val > info.txt
但我想將 stderr 從那一行重定向到/dev/null
。
顯然以下方法不起作用:
cmd -opt val > info.txt > /dev/null
怎么做?
補充:請注意,我不希望將任何常規 output 寫入終端; 所有常規 output 應寫入指定文件info.txt
。
>
和2>
是獨立的,可以出現在同一個命令中。
cmd -opt val > info.txt 2> /dev/null
標准 output 被重定向到info.txt
,標准錯誤被重定向到/dev/null
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.