Last active
November 9, 2023 00:27
-
-
Save dev01d/4cf9c727cae3b2a90f9779ffc4135b1d to your computer and use it in GitHub Desktop.
Fix all directory and file permissions (even dot files).
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
#!/usr/bin/env bash | |
# | |
## | |
### Fix file pemissions | |
### dirs 755 files 644 | |
## | |
# | |
CWD="$(pwd)" | |
echo -e "\e[1;25;33m\nFixes file and dir perms in current working directory\e[0m\n" | |
read -p "Include hidden files (Y/n)? " answer | |
case ${answer:-y} in | |
y|* ) | |
echo -e "\e[1;25;32m\nFixing Files (755)\e[0m" | |
find $CWD -type d -exec chmod 755 {} \; | |
echo -e "\e[1;25;32mFixing Files (644)\e[0m" | |
find $CWD -type f -exec chmod 644 {} \; | |
;; | |
n|N ) | |
echo -e "\e[1;25;32m\nFixing Files (755)\e[0m" | |
find $CWD -not -path '*/.*' -type d -exec chmod 755 {} \; | |
echo -e "\e[1;25;32mFixing Files (644)\e[0m" | |
find $CWD -not -path '*/.*' -type f -exec chmod 644 {} \; | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment