Created
February 6, 2014 11:51
-
-
Save HedgeMage/8842703 to your computer and use it in GitHub Desktop.
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 | |
# exit this bash script if any statement returns a non-true return value (same as: set -e) | |
set -o errexit | |
if [ -z "$1" ]; then | |
echo | |
echo "ERROR: Must pass parameter of path to directory (which will have permissions set accordingly; 775 directories and 664 files)." | |
echo "USAGE: $0 /path/to/directory" | |
echo | |
exit 1 | |
fi | |
echo | |
echo "Working recursively with directory $1 this script will chmod 775 all directories and chmod 664 all files." | |
read -p "Okay to continue (y/n)? " | |
if [ "$REPLY" != "y" ]; then | |
echo | |
echo "EXITING -- NO ACTION TAKEN." | |
echo | |
exit 1 | |
fi | |
echo | |
echo "Starting..." | |
echo | |
find "$1" -type d -print0 | xargs -0 chmod 775 | |
find "$1" -type f -print0 | xargs -0 chmod 664 | |
echo "Done." | |
echo | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment