-1

This question already has an answer here:

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

marked as duplicate by Michael Homer, jasonwryan, Anthon, Stephen Kitt, slm Mar 30 '15 at 12:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from serverfault.com Mar 30 '15 at 4:29

This question came from our site for system and network administrators.

  • @peterh what do you mean? – John Selm Mar 29 '15 at 1:23
1

I've corrected some statements, removed some ; and formatted once more. This is the working result:

#checks if speed is 150
if [ $2 -eq 150 ] ; then
    words=0
    starttime=$(date +%s)
    FS=$'\n'
    for j in $(grep --color=always -iP '\b[^aeiou\s]*[aeiou][^aeiou\s]*\K[aeiou]' $1) ; do
        #Reads the text file in the centre of the screen
        echo "                                                    ___________________"
        echo "                                                             $j";
        echo "                                                    ___________________"
        echo "                                                          Speed 150 wpm"
        sleep  0.9
        clear
        words=$(( $words + 1 ))
    done

    endtime=$(( $(date +%s) - $starttime ))
    echo "You read $words words in $endtime seconds!"

    exit 8
fi
  • Thanks for the reply, but this solution hasn't really worked! I am still getting the error. I checked the entire script, but the syntax seems ok! I guess I need to wait for Monday and see my Professor! – John Selm Mar 29 '15 at 19:26
  • Could it be because I have used variables startime and endtime multiple times in my script? – John Selm Mar 29 '15 at 22:01
  • More in using the variable $words_read which is not set. – ott-- Mar 29 '15 at 22:08
  • Thank you for the help. I have found the error and fixed it! Thanks – John Selm Mar 29 '15 at 22:10