I am trying to create an spritz app. Everything was working fine, but since yesterday I keep getting this error: ./spritz: line 176: syntax error: unexpected end of file
I have checked the script file and everything seems perfect. I am confused, I have an if statement at last and it looks correct! Here is the last portion:
#checks if speed is 150
157 if [[ $2 -eq 150 ]];
158 then
159 starttime=$SECONDS
160 FS=$'\n'
161 for j in `grep --color=always -iP '\b[^aeiou\s]*[aeiou][^aeiou\s]*\K[aeiou]' $1`;
162 do
163 #Reads the text file in the centre of the screen
164 echo " ___________________"
165 echo " $j";
166 echo " ___________________"
167 echo " Speed 150 wpm"
168 sleep 0.9;
169 clear;
170 done
171 endtime=$(($SECONDS - $starttime))
172 echo "You read $words_read words in $endtime seconds!"
173 exit 8
174 fi
;
(semicolon) at the end of a line. You can delete the semicolons at the ends of lines 157, 161, 165, 168, and 169. (Or you can leave them in; I guess it’s a question of style.) … (Cont’d) – Scott Mar 29 at 7:46"$1"
,"$2"
,"$SECONDS"
, and"$starttime"
. (3) It’s easier to read and debug code that’s indented properly. (4) Why are you settingFS
and then not using it? (5)`…`
can be written$(…)
. (6)$(($SECONDS - $starttime))
can equivalently be written$((SECONDS - starttime))
. Again, this is basically an issue of style. (7) Why are you printing"$words_read"
in the loop when you aren’t modifying it in the loop? – Scott Mar 29 at 7:48`grep …`
with a list of values. In other words, use the process of elimination. – Scott Mar 29 at 7:50"$1"
needs quoting, (ad 4) probably he meantIFS
(and notFS
)? – Janis Mar 30 at 0:05