#!/bin/sh if ! test $# -eq 3 then echo missing arguments. :: directory-perm file-perm path ... exit 1 fi command=chmod find "$3" -type d -exec $command "$1" {} \; find "$3" -type f -exec $command "$2" {} \;