This is wat I have, I used "elif" before but it worked the same. Ok the first 2 if statements work but the last 2 don't. For example here are the files in your dir:
10 11.txt 12 14.txt
When you run this script: (called script1)
script1 10 - it doesn't prompt for txt extension!
It should now say "Must have txt extension!"
I don't know what I am doing wrong, this seems so simple but I can't hack it!
Please help,
theA
if [ "$#" -eq 0 ]
then
echo "Name required!"
exit 1
fi
if [ "$#" -gt 1 ]
then
echo "Only one please!!"
exit 1
fi
if [ ! -e "$1" ]
then
echo "Database file \"$1\" does not exist!"
exit 1
fi
if [ "-f" = ".txt$" ]
then
echo "Database files must contain a "txt" extension!"
exit 1
fi
if [ ! -e $1 ]
then
echo "Database file \"$1\" does not exist!"
exit 1
fi
if [ ! `echo $1 | grep ".txt$"` ]
then
echo "Database files must contain a "txt" extension!"
exit 1
fi