I'm trying to put the 'f-$count'(f-1,f-2) name into the array.
Below is the code,
echo "Enter the count"
read count
echo $count
#arr=()
i=1
while true;
do
if ["$i" -gt "$count"]; then
exit 0
else
arr[$i]=f-$i
i=$((i+1))
fi
done
echo ${arr[@]}
I'm getting the error as 'script.sh: line 11: [3570: command not found ' continuously.
In shell programming, the brackets in the
if
MUST be delimited by spaces:MUST be:
[EDIT] The left bracket (
[
) is actually a built-in shell command and so requires the space afterwards to delimit it from its parameters, as with any command.