Skip to content

Instantly share code, notes, and snippets.

@quickgrid
Created April 1, 2016 04:15
Show Gist options
  • Save quickgrid/c65ffc424c498d47e5f43347d88626fb to your computer and use it in GitHub Desktop.
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.
#!/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