I am trying to learn shell scripting, so I created a simple script with a loop that does nothing:
#!/bin/bash
names=(test test2 test3 test4)
for name in ${names[@]}
do
#do something
done
however, when I run this script I get the following errors:
./test.sh: line 6: syntax error near unexpected token done’
./test.sh: line 6: done’
What have I missed here? are shell scripts ‘tab sensitive’?
No, shell scripts are not tab sensitive (unless you do something really crazy, which you are not doing in this example).
You can’t have an empty
while do doneblock, (comments don’t count)Try substituting
echo $nameinsteadoutput