Here I have a basic bash script written. I want the if blocks to organize where to write output to. Is there a syntax error with the way I have written my conditional logic? The error I am getting is for every line where I have an if or elif statement. I believe it may have something to do with the -eq comparison operator or possibly a lack or parentheses.
Here is an example of the error I am having (the last errors that occur in the terminal; closest to the bottom):
./lit: line 17: [2: command not found
./lit: line 20: [2: command not found
./lit: line 23: [2: command not found
./lit: line 28: [3: command not found
./lit: line 31: [3: command not found
./lit: line 34: [3: command not found
./lit: line 37: [3: command not found
./lit: line 42: [3: command not found
./lit: line 45: [3: command not found
./lit: line 48: [3: command not found
./lit: line 51: [3: command not found
./lit: line 56: [3: command not found
./lit: line 59: [3: command not found
./lit: line 62: [3: command not found
./lit: line 65: [3: command not found
for i in {0..2};
do
for j in {0..3};
do
for k in {0..3}
do
for l in {0..3}
do
START=$(date +%s.%N)
#some command here
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
if ["$i" -eq "0"];
then
echo "test$i$j$k$l $DIFF" >> repeatSample.txt;
elif ["$i" -eq "1"]
then
echo "test$i$j$k$l $DIFF" >> writeZeroes.txt
elif ["$i" -eq "2"]
then
echo "test$i$j$k$l $DIFF" >> repeatPacket.txt
fi
if [$j -eq 0]
then
echo "test$i$j$k$l $DIFF" >> byte15.txt
elif [$j -eq 1]
then
echo "test$i$j$k$l $DIFF" >> byte100.txt
elif [$j -eq 2]
then
echo "test$i$j$k$l $DIFF" >> byte500.txt
elif [$j -eq 3]
then
echo "test$i$j$k$l $DIFF" >> byte1000.txt
fi
if [$k -eq 0]
then
echo "test$i$j$k$l $DIFF" >> loss10.txt
elif [$k -eq 1]
then
echo "test$i$j$k$l $DIFF" >> loss22.txt
elif [$k -eq 2]
then
echo "test$i$j$k$l $DIFF" >> loss37.txt
elif [$k -eq 3]
then
echo "test$i$j$k$l $DIFF" >> loss50.txt
fi
if [$l -eq 0]
then
echo "test$i$j$k$l $DIFF" >> pinkpanth.txt
elif [$l -eq 1]
then
echo "test$i$j$k$l $DIFF" >> poeee.txt
elif [$l -eq 2]
then
echo "test$i$j$k$l $DIFF" >> dooors.txt
elif [$l -eq 3]
then
echo "test$i$j$k$l $DIFF" >> simplehead.txt
fi
done
done
done
done