Skip to content

Instantly share code, notes, and snippets.

@kbence
Created February 3, 2014 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbence/8786829 to your computer and use it in GitHub Desktop.
Save kbence/8786829 to your computer and use it in GitHub Desktop.
Script to give all permission to others exactly group has (750 -> 755) in the current directory (including the directory itself)
#!/bin/bash
find $(pwd) | while read file; do
PERMS=$(stat --format %a $file)
NEW_PERMS=$(echo $PERMS | awk '{printf("%s%s", substr($0, 1, 2), substr($0, 2, 1))}')
if [ "$PERMS" != "$NEW_PERMS" ]; then
COMMAND="chmod $NEW_PERMS $file"
echo $COMMAND "# had $PERMS"
$COMMAND
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment