#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: filechecker filename"
echo " Will show various attributes of the file given."
exit 255
fi
file_count=$(find . -name $1 | wc -l)
#echo $file_count
echo $1
if [ "$file_count" -gt 1 ]; then
echo " has multiple version exists in the current directory and it's subdirectories,exiting."
# Leave script now
exit 2
fi
if [ "$file_count" -eq 0 ]; then
echo " does not exist,exiting."
exit 1
# Leave script now
fi
if [ -f $1 ] ; then
echo is a file.
elif [ -d $1 ] ; then
echo is a directory.
fi
if [ -x $1 ] ; then
echo Is executable.
fi
if [ -r $1 ] ; then
echo Is readable.
else
echo Is not readable.
fi
if [ -w $1 ] ; then
echo Is writable.
fi
if [ -s $1 ] ; then
echo Is not empty.
else
echo Is empty.
fi
exit 0
if [ $# -ne 1 ]; then
echo "Usage: filechecker filename"
echo " Will show various attributes of the file given."
exit 255
fi
file_count=$(find . -name $1 | wc -l)
#echo $file_count
echo $1
if [ "$file_count" -gt 1 ]; then
echo " has multiple version exists in the current directory and it's subdirectories,exiting."
# Leave script now
exit 2
fi
if [ "$file_count" -eq 0 ]; then
echo " does not exist,exiting."
exit 1
# Leave script now
fi
if [ -f $1 ] ; then
echo is a file.
elif [ -d $1 ] ; then
echo is a directory.
fi
if [ -x $1 ] ; then
echo Is executable.
fi
if [ -r $1 ] ; then
echo Is readable.
else
echo Is not readable.
fi
if [ -w $1 ] ; then
echo Is writable.
fi
if [ -s $1 ] ; then
echo Is not empty.
else
echo Is empty.
fi
exit 0