I'm receiving an error saying line 44: syntax error: unexpected end of file

#!/bin/sh touch $results.txt #creates txt file now="$(date)" #records current date and time to be posted echo "Name: Kevin Delrisco" > results.txt echo "Date and time: $now" >> results.txt echo -n "Enter a number between 1-50: " # asks user to enter a number read n while [[$n -le 1 || $n -ge 51 ]] do #while loop to check if number is over 50 echo -n "Enter a number between 1-50: " read n; done sum= 0 for (( i = 1; i<=$n; i++ )) do #for loop to add the sum sum=$(( $sum + $i )); done echo "Sum of numbers is $sum" echo "Sum of numbers is $sum" >> results.txt 
1

1 Answer

read n done 

This reads two values from the input into $n and $done.

Insert ; or a newline before done to make it close the while loop.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy