Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 尝试将curl脚本从Linux转换到Windows,以便能够下载Google Drive大型文件_Bash_Batch File_Curl_Awk - Fatal编程技术网

Bash 尝试将curl脚本从Linux转换到Windows,以便能够下载Google Drive大型文件

Bash 尝试将curl脚本从Linux转换到Windows,以便能够下载Google Drive大型文件,bash,batch-file,curl,awk,Bash,Batch File,Curl,Awk,我找到了在Linux上工作的代码: #!/bin/bash fileid="FILEIDENTIFIER" filename="FILENAME" curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=

我找到了在Linux上工作的代码:

#!/bin/bash
fileid="FILEIDENTIFIER"
filename="FILENAME"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
资料来源:

问题是需要为Windows实现更换awk

我发现这样做的方式是,而不是:

command | awk '{ print $4 }'
做一些类似于:

for /f "tokens=4" %%a in ('command') do echo %%a
我的问题是我不熟悉awk和NF变量。所以我真的不知道如何在批处理实现中转换$NF来做完全相同的事情

我找到了解决办法。芬德斯特成功了。 因此,现在它与以下各项完美配合:

for /f "tokens=7" %%a in ('findstr "download" cookie.txt') do echo %%a

对于在Windows上使用批处理脚本上的curl下载大型Google驱动器文件的全功能脚本,回答此问题的代码是:

curl -c cookie.txt -s -L "https://drive.google.com/uc?export=download&id=FILE_ID" > nul
for /f "tokens=7" %%a in ('findstr "download" cookie.txt') do curl -Lb cookie.txt "https://drive.google.com/uc?export=download&confirm=%%a&id=YOUR_FILE_ID" -o FILENAME

只需将文件ID替换为您的Google Drive文件标识符,将文件名替换为您所需的输出文件名。

您可以雇佣Airtasker上的人员。您可以将Unix工具添加到Windows中,以尝试使其更强大。。。谢谢你,马克,但这个脚本将被共享,我想让它尽可能的本土化。至少curl现在是现代Windows系统的原生版本。