I need to make a shell script that accepts a directory input by the user. The program searches for the directory and finds if it exists or not. Then if it does exist, it outputs the number of files within that directory. Here's what I have so far.
result=
echo "Please input a directory: \c"
read directory
if [-d "$directory"];
then
result=ls -l . | egrep -c '^-'
echo "The file $directory is a directory with the # of ordinary files: $
result"
else
echo "The file $directory is not a directory or does not exist."
fi
I fixed a typo in my example with back quotes, but that shouldn't have generated the error you are seeing. Can you post the script that is giving you the error so we can see what you are trying?