#!/bin/bash check_dir_group() { if [ -G $DIR ] ; then echo "dir $DIR belongs to your group" else echo "dir $DIR is foreign to your group" fi } check_dir_owner() { if [ -G $DIR ] ; then echo "dir $DIR belongs to you" else echo "dir $DIR is foreign to you" fi } check_file_group() { if [ -G $FILE ] ; then echo "file $FILE belongs to your group" else echo "file $FILE is foreign to your group" fi } check_file_owner() { if [ -O $FILE ] ; then echo "file $FILE belongs to you" else echo "file $FILE is foreign" fi } for FILE in $(find ./* -type f) ; do check_file_group check_file_owner done for DIR in $(find ./* -type d) ; do check_dir_group check_dir_owner done