Created
April 1, 2016 04:15
-
-
Save quickgrid/c65ffc424c498d47e5f43347d88626fb to your computer and use it in GitHub Desktop.
The code below traverses all the directories recursively inside the passed in command line argument directory. While traversing recursively if it finds a regular file with executable permission it remove the permission for the owner.
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 | |
#Recursively traverse the directories | |
traverseDirectory(){ | |
for fileName in `ls $1/` | |
do | |
echo "$1/$fileName" | |
if [ -x $1/$fileName ]; then | |
chmod o-x "$1/$fileName" | |
fi | |
if [ -d $1/$fileName ]; then | |
echo "$1/$fileName" | |
traverseDirectory "$1/$fileName" | |
fi | |
done | |
} | |
traverseDirectory "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment