Created
December 13, 2012 06:14
-
-
Save anonymous/4274476 to your computer and use it in GitHub Desktop.
Simple script that can be used to copy the file permissions and ownership for a directory tree to another machine. Run it first on a machine that has the correct permissions, capturing the output to a text file. Transfer that text file to the target machine and run it as a script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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