Dan*_*nte 4 shell bash shell-script
我试图让这个 while 循环(使用 nano)从这个 URL 下载一些网站,但我不断收到错误“意外标记‘完成’附近的语法错误”:
while read <FIRST-LAST> do
echo FIRST-LAST
curl -O https://www.uoguelph.ca/arts/history/people/FIRST-LAST
done < formatted_history.txt
Run Code Online (Sandbox Code Playgroud)
do应该出现在一个新行上,要么需要在它前面插入一个分号<FIRST-LAST>实际上应该是shell变量的名称,并且FIRST-LAST应该是对该变量的引用。 <并且>不是 shell 变量的合法字符,因此我们可以推断必须在此处替换其他内容。 person在这种特殊情况下,似乎与任何变量名一样好。我认为这样的事情应该工作得更好:
while read person ; do
echo "${person}"
curl -O "https://www.uoguelph.ca/arts/history/people/${person}"
done < formatted_history.txt
Run Code Online (Sandbox Code Playgroud)
这假设该文件formatted_history.txt实际上存在于当前目录中,并且是来自https://www.uoguelph.ca/arts/history/people/页面的人员列表- 类似于:
tara-abraham
donna-andrew
susan-armstrong-reid
... etc ...
Run Code Online (Sandbox Code Playgroud)