Reputation: 2368
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
Upvotes: 2
Views: 108
Reputation: 3223
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.
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
Upvotes: 1