set-permission-normal.sh 502 B

123456789101112131415161718
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. # Set the desired permissions for files and directories
  4. file_permissions=644
  5. directory_permissions=755
  6. # Find all files and directories recursively
  7. while IFS= read -red '' file; do
  8. if [[ -f $file ]]; then
  9. chmod -v "$file_permissions" "$file"
  10. elif [[ -d $file ]]; then
  11. chmod -v "$directory_permissions" "$file"
  12. else
  13. echo "Skipping: ${file} is not a regular file or directory"
  14. fi
  15. done < <(find . -print0)