Skip to content

Instantly share code, notes, and snippets.

@JT5D
Forked from bradmontgomery/chmown.sh
Created November 4, 2013 04:47
Show Gist options
  • Select an option

  • Save JT5D/7298200 to your computer and use it in GitHub Desktop.

Select an option

Save JT5D/7298200 to your computer and use it in GitHub Desktop.
#!/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