Skip to content

Instantly share code, notes, and snippets.

@BennettSmith
Forked from anonymous/copy-perms.sh
Created December 13, 2012 06:15
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 BennettSmith/4274481 to your computer and use it in GitHub Desktop.
Save BennettSmith/4274481 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Create the script that emits values for a single file using stat.
cat >/tmp/fileperms.sh <<FILEPERMS
#!/bin/bash
echo chmod `stat -f '%Lp' \$1` \"\$1\"
echo chown `stat -f '%u' \$1`:`stat -f '%g' \$1` \"\$1\"
FILEPERMS
# Make sure the script is executable
chmod a+x /tmp/fileperms.sh
# Walk the tree, running the script for each file
find . -depth -exec /tmp/fileperms.sh {} \;
# Cleanup
rm /tmp/fileperms.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment