简体   繁体   English

linux 命令的输出没有从控制台被抑制

[英]The output of linux command is not getting suppressed from console

I am using the below command to remove write access for "other" users:我正在使用以下命令删除“其他”用户的写访问权限:

    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

I need all error and output messages to be suppressed from console.我需要从控制台抑制所有错误和输出消息。 I'm however getting this messages still:但是,我仍然收到此消息:

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

I tried all combinations like this at the end of my command:我在命令结束时尝试了所有这样的组合:

&> /dev/null
>/dev/null 2>&1
2&>1 >/dev/null

But it doesn't help.但它没有帮助。 My shell is :我的外壳是:

# echo $SHELL
/bin/bash

Kindly help请帮忙

You are close to your answer.你很接近你的答案。 Since the error is coming from the find command, you need to redirect the error of xargs -I '{}' find '{}' -xdev -type f -perm -0002 command.由于错误来自 find 命令,您需要重定向xargs -I '{}' find '{}' -xdev -type f -perm -0002命令的错误。

So it would be:所以它会是:

xargs -I '{}' find '{}' -xdev -type f -perm -0002 2>/dev/null

Also, as stated by @HuStmpHrrr to redirect the error messages for your entire long command, use {long_command;} 2>/dev/null此外,如@HuStmpHrrr 所述,重定向整个长命令的错误消息,请使用{long_command;} 2>/dev/null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM