Command not found

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:
    Trying to run script but everytime I do I get teh following error message
line 4: [1: command not found

I have attempted different version but still come up with same results.

  1. Relevant commands, code, scripts, algorithms:
#!/bin/bash
count=1
echo "start of the program"
while [$count -1e 10]
do
echo "Loop #$count"
sleep 10
count=$[count+1]
done
echo "end of the program"
  1. The attempts at a solution (include all code and scripts):
    I have attempted to change path to include directory of where script is located
    I have ensured the script is executable
    I have changed -1e to -i no change in affect

  2. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

University of Phoenix/Honolulu, HI/US/Moore/Introduction to Unix

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

# wrong
while[$count -1e 10]

# right
while [ $count -le 10 ]

I've tried ...

while[$count -le 10]

with same results, but when I included the space before and after ...

while [ $count -le 10 ]

it worked. Why does that space matter?

It is a syntax rule.

The same reason you can't put enter keys anywhere you like. That's simply the way the language expects it.

Perhaps an interesting backgrounder is, that [ is one of the names of the 'test' utility (see ls -l /bin/[ ) and in this case it takes 4 parameters : $count , -le , 10 , and ]

2 Likes