Skip to content

Instantly share code, notes, and snippets.

@bradmontgomery
Created August 14, 2010 03:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bradmontgomery/523896 to your computer and use it in GitHub Desktop.
Save bradmontgomery/523896 to your computer and use it in GitHub Desktop.
A combination of chmod & chown
#!/bin/bash
# Usage: chmown [options] <chmod-args> <chown-user>[:<chown-group>]
chmown () {
options=''
while [ -n "$(echo $1 | grep '-')" ]; do
options="$options $1"
shift
done
chmodcmd="chmod $options $1"
shift
chowncmd="chown $options $1"
shift
while [ -n "$1" ]; do
chmodcmd="$chmodcmd $1"
chowncmd="$chowncmd $1"
shift
done
$chmodcmd
$chowncmd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment