We can test if a directory is writable by the uid of the current process:
if [ -w $directory ] ; then echo \'Eureka!\' ; fi
But can anyone
alias wbyu='_(){ local -i FND=0; if [[ $# -eq 2 ]]; then for each in $(groups "$1" | awk "{\$1=\"\";\$2=\"\"; print \$0}"); do (($(find "${2}" \( -perm /220 -o -group "$each" -a -perm /g+w \) 2>/dev/null | wc -l))) && FND=1; done; else echo "Usage: wbyu
I put it into an alias it takes two arguments, the first is the user and the second is the directory to check. It looks for permissions writable by anyone and also loops over the groups of the specified user to check if the directory is in the user group and writable - if either gets a hit it sets a found flag and prints Eureka! at the end.
IOW:
FND=0
USER=user1
DIR=/tmp/test
for each in $(groups "$USER" | awk '{$1="";$2=""; print $0}'); do
(($(find "$DIR" \( -perm /220 -o -group "$each" -a -perm /g+w \)\
2>/dev/null | wc -l))) && FND=1
done
(($FND)) && echo 'Eureka!'