Skip to content

Instantly share code, notes, and snippets.

@darencard
Created August 1, 2017 18:58
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save darencard/079246e43e3c4b97e373873c6c9a3798 to your computer and use it in GitHub Desktop.
Save darencard/079246e43e3c4b97e373873c6c9a3798 to your computer and use it in GitHub Desktop.
Script to download files from Google Drive using Bash
#!/usr/bin/env bash
# gdrive_download
#
# script to download Google Drive files from command line
# not guaranteed to work indefinitely
# taken from Stack Overflow answer:
# http://stackoverflow.com/a/38937732/7002068
gURL=$1
# match more than 26 word characters
ggID=$(echo "$gURL" | egrep -o '(\w|-){26,}')
ggURL='https://drive.google.com/uc?export=download'
curl -sc /tmp/gcokie "${ggURL}&id=${ggID}" >/dev/null
getcode="$(awk '/_warning_/ {print $NF}' /tmp/gcokie)"
cmd='curl --insecure -C - -LOJb /tmp/gcokie "${ggURL}&confirm=${getcode}&id=${ggID}"'
echo -e "Downloading from "$gURL"...\n"
eval $cmd
@ricardo78
Copy link

ricardo78 commented Sep 12, 2022

Hi there, this is great. But I'm having an issue with the following error: curl: --continue-at and --remote-header-name cannot be combined

I'm not entirely sure what's happening here, and I'm unable to fix this. Any pointers? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment