Syntax Error: unexpected end of file — Bash script

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[^aeious]*[aeiou][^aeious]*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

What could cause that error?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The diagnostic “unexpected end of file” is a hint that you have some unmatched or unterminated opening syntactical construct (if w/o fi, do w/o done, opening brackets w/o the associated closing one, opening but unterminated quotes, etc.). The line number pointing to the end of the script is not helpful in this case, beyond saying to inspect your syntactical constructs; the error may be anywhere in your code. You have to check that.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x