#!/bin/bash folderperm() { [[ ! -d $1/ ]] && $1/ is not a folder && exit 1 chown -R elge:elge $1/ [[ -d $1/lost+found/ ]] && chown -R root:root $1/lost+found/ find $1/ -type f -exec chmod 644 {} \; find $1/ -type d -exec chmod 755 {} \; find $1/ ! -type f ! -type d } [[ -z $@ ]] && echo what folder? && exit 1 for folder in $@; do folderperm $folder done; unset folder