Skip to content

Instantly share code, notes, and snippets.

@staroselskii
Created April 17, 2014 16:05
Show Gist options
  • Save staroselskii/10994648 to your computer and use it in GitHub Desktop.
Save staroselskii/10994648 to your computer and use it in GitHub Desktop.
lab3
#!/usr/bin/ksh
if [ ! $# -eq 1 ]
then
echo "Wrong input"
exit 1
fi
USER="$1"
id "$USER" 1>/dev/null 2>&1 || { echo "No such user"; exit 1; }
GROUPS=$(/usr/xpg4/bin/id -G -n "$USER") #get all groups
GROUPS=$(echo "$GROUPS" | sed -e 's/ / -o -group /g' -e 's/^/-group /g') #separate them by '-o -group'
{
gfind . -type d -user "$USER" -perm /u=w
gfind . -type d -perm /g=w \( $GROUPS \)
gfind . -type d -perm /o=w
} | sort -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment