Skip to content

Instantly share code, notes, and snippets.

@quickgrid
Created April 1, 2016 04:03
Show Gist options
  • Save quickgrid/10f6be3e31ae582e148171ce4c1aac37 to your computer and use it in GitHub Desktop.
Save quickgrid/10f6be3e31ae582e148171ce4c1aac37 to your computer and use it in GitHub Desktop.
The code below checks if the given command line argument is a regular file. If it is then it checks if the file is executable. Finally if the file is executable the code removes the execution permission for the owner.
#!/bin/bash
removeExecutablePermission(){
if [ -f $1 ]; then
#echo "regular file"
if [ -x $1 ]; then
#echo "remove permission"
chmod o-x $1
fi
fi
}
removeExecutablePermission "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment