- 11,462
- U.K
- Paganisterr
- Ak Paganister
Hi all
I have a quick question. I've just started learning the unix scripting language (and also the first language I've tried to learn significantly) and have a problem I can not for the life of me figure out. I presume it's a tiny syntax issue at the beginning of the loop but I swear it's layed out the same as examples on the 'net.
Basically I'm just creating a small loop which asks the user to input x amount of files and want it to loop that many times. The errors that appear are:
Here's the code:
Any help? Please?
I have a quick question. I've just started learning the unix scripting language (and also the first language I've tried to learn significantly) and have a problem I can not for the life of me figure out. I presume it's a tiny syntax issue at the beginning of the loop but I swear it's layed out the same as examples on the 'net.
Basically I'm just creating a small loop which asks the user to input x amount of files and want it to loop that many times. The errors that appear are:
test2: line 3: x: command not found
test2: line 4: [: -lt: unary operator expected
Here's the code:
Code:
echo "Please enter the number times you want to check for a file:"
read OPTION
x = "0"
while [ $x -le $OPTION ]
do
echo "Enter filename"
read FILENAME
if [ -e $FILENAME ]
then echo "File" $FILENAME "does exist."
else
echo "File" $FILENAME "does not exist."
fi
done
Any help? Please?
Last edited: