[英]The output of linux command is not getting suppressed from console
我正在使用以下命令刪除“其他”用戶的寫訪問權限:
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -perm -0002 | awk -F"/" {'if ($5!="tmp") print $0'} | xargs chmod o-w
我需要從控制台抑制所有錯誤和輸出消息。 但是,我仍然收到此消息:
find: /data0101/track_logs/IMEI_TRACK_9_20141127_01010014.LOG: No such file or directory
find: /data0101/track_logs/IMEI_TRACK_4_20141123_01010014.LOG: No such file or directory
find: /data0101/track_logs/IMEI_TRACK_7_20141122_01010014.LOG: No such file or directory
我在命令結束時嘗試了所有這樣的組合:
&> /dev/null
>/dev/null 2>&1
2&>1 >/dev/null
但它沒有幫助。 我的外殼是:
# echo $SHELL
/bin/bash
請幫忙
你很接近你的答案。 由於錯誤來自 find 命令,您需要重定向xargs -I '{}' find '{}' -xdev -type f -perm -0002
命令的錯誤。
所以它會是:
xargs -I '{}' find '{}' -xdev -type f -perm -0002 2>/dev/null
此外,如@HuStmpHrrr 所述,重定向整個長命令的錯誤消息,請使用{long_command;} 2>/dev/null
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.