Why is the value if this string executing in a bash script?
- by Ross
Hello
Why is this script executing the string in the if statement:
#!/bin/bash
FILES="*"
STRING=''
for f in $FILES
do
if ["$STRING" = ""]
then
echo first
STRING='hello'
else
STRING="$STRING hello"
fi
done
echo $STRING
when run it with sh script.sh outputs:
first
lesscd.sh: line 7: [hello: command not found
lesscd.sh: line 7: [hello hello: command not found
lesscd.sh: line 7: [hello hello hello: command not found
lesscd.sh: line 7: [hello hello hello hello: command not found
lesscd.sh: line 7: [hello hello hello hello hello: command not found
hello hello hello hello hello hello
p.s. first attempt at a shell script
thanks