Omitting files when parsing directories

The below script lets you omit files and folders when being invoked with the -o switch.


omit_files.sh


#!/bin/sh

#Variables
entry=
omit=
file_to_omit=

### Point of entry ###

while getopts ":o:" opt ; do
	case $opt in
                o)
			o="$o $(readlink -f ${OPTARG})"
                        ;;
                \?)
                        echo "unkown flag: -$OPTARG."
                        exit
                        ;;
        esac
done
shift $((OPTIND-1))

contents=*

for entry in $contents ; do
	omit=0
	entry=$(readlink -f $entry)

	for file_to_omit in $o ; do
		if [ -e $file_to_omit ] && [ "$file_to_omit" = "$entry" ] ; then
			omit=1
			break
		fi
	done

	if [ $omit -eq 1 ] ; then
		:
	else
		echo $entry
	fi

done

exit 0