unix - 为什么在这种情况下 curl 失败?

标签 unix curl download

我正在尝试从以下链接下载文件:

http://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?tool=portal&sendto=on&log$=seqview&db=nuccore&dopt=gilist&sort=&query_key=1&qty=12654729&filter=all

将上述链接粘贴到网络浏览器(Chrome)的地址栏中时,它允许我将文件另存为“sequence.gi.txt”。

但是,当我在终端中尝试该操作时,出现以下错误:
curl -o test.txt http://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?tool=portal&sendto=on&log$=seqview&db=nuccore&dopt=gilist&sort=&query_key=1&qty=12654729&filter=all
[1] 30036
[2] 30037
[3] 30038
[4] 30039
[5] 30040
[6] 30041
[7] 30042
[8] 30043
-bash: log$=seqview: command not found
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
101  7297    0  7297    0     0  59633      0 --:--:-- --:--:-- --:--:-- 79315
[1]   Done                    curl -L -o test.txt http://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?tool=portal
[2]   Done                    sendto=on
[3]   Exit 127                log$=seqview
[4]   Done                    db=nuccore
[5]   Done                    dopt=gilist
[6]   Done                    sort=
[7]-  Done                    query_key=1
[8]+  Done                    qty=12654729

如何在命令行中下载文件?

最佳答案

网址中的&告诉bash,它之前的所有内容都是应该在后台运行的命令。因此,每个&之后的所有内容都被解释为在后台运行的新命令,这就是为什么当您尝试运行命令时看到一堆假流程开始的原因。尝试将网址放在单引号'http://....'中,以避免bash将$和&字符解释为特殊字符:

curl -o test.txt 'http://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?tool=portal&sendto=on&log$=seqview&db=nuccore&dopt=gilist&sort=&query_key=1&qty=12654729&filter=all'

关于unix - 为什么在这种情况下 curl 失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17707884/

相关文章:

java - 是否有一个与/dev/null 等效的文件可以在 Windows 和 Unix 上运行?

bash - 获取错误 cp : cannot stat when trying to copy files from one folder to another

C++ LibcURL IMAP 获取主题行的变量是什么?

bash - 如何使用 wget 或 curl 获取可用文件列表?

visual-studio-2013 - 如何下载 Visual Studio 2013 更新 2 离线/独立安装?

iPhone SDK : How do you download video files to the Document Directory and then play them?

Linux/Unix 查找命令

java - Spring - cURLS 不使用 Jackson XML Mapper 反序列化

ajax - 从 ajax 和 ActionResult 下载文件

linux - UNIX基本getopts麻烦