4

I'm trying to get this while loop (using nano) to download some websites from this URL but I keep getting the error "syntax error near unexpected token `done'":

while read <FIRST-LAST> do
        echo FIRST-LAST
        curl -O https://www.uoguelph.ca/arts/history/people/FIRST-LAST
done < formatted_history.txt
4
  • Either the do should appear on a new line, or it needs to have a semi-colon inserted in front of it
  • <FIRST-LAST> should actually be the name of a shell variable, and FIRST-LAST should be a reference to that variable. < and > are not legal characters for shell variables, so we can deduce that something else must be substituted here instead. person seems to be as good a variable name as any in this particular case.

I think something like this should work much better:

while read person ; do
        echo "${person}"
        curl -O "https://www.uoguelph.ca/arts/history/people/${person}"
done < formatted_history.txt

This assumes that the file formatted_history.txt actually exists in the current directory and is a list of people from the https://www.uoguelph.ca/arts/history/people/ page - something like:

tara-abraham
donna-andrew
susan-armstrong-reid
... etc ...
  • 3
    THANK YOU SO MUCH! This worked perfectly, I can't explain how long this has taken me and you just answered it. Thank you!!! – Daniela Bustamante Jan 20 '17 at 1:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.