我一直在尝试创建一个简单的脚本,它将从.txt文件中获取一个查询列表,附加主url变量,然后擦除内容并将其输出到文本文件.
这是我到目前为止
#!/bin/bash url="example.com/?q=" for i in $(cat query.txt); do content=$(curl -o $url $i) echo $url $i echo $content >> output.txt done
列表:
images news stuff other
错误日志:
curl: (6) Could not resolve host: other; nodename nor servname provided,or not known example.com/?q= other
curl -L http://example.com/?q=other >> output.txt
最终我希望输出是:
fetched: http://example.com/?q=other content: the output of the page followed by the next query in the list.
使用更多的报价!
原文链接:https://www.f2er.com/bash/386678.html> http://mywiki.wooledge.org/Quotes
> http://mywiki.wooledge.org/Arguments
> http://wiki.bash-hackers.org/syntax/words
改为:
url="example.com/?q=" for i in $(cat query.txt); do content="$(curl -s "$url/$i")" echo "$content" >> output.txt done