[SOLVED] Counting variables in bash script
If I read in variables entered by the user, how can I check to make sure the correct number of variables were entered? For example, after reading in a data file and making it into an array, I have:
echo "To check the data, enter the first element number, last element number and step size as x y z:"
read x y z
It then goes on to start a loop, but what I would like now (before the loop) is a check to see if three variables have been entered, before the rest of the script continues.
I've tried specifying the variables as $1, $2 and $3, but if I echo $#, the value comes out as zero, so it's obviously not working.
Can anyone please offer any help?
Thanks in advance,