Skip to content

Instantly share code, notes, and snippets.

@rama982
Last active April 11, 2022 20:56
Show Gist options
  • Save rama982/222c3bdaa6a1160288b6f0d17045cead to your computer and use it in GitHub Desktop.
Save rama982/222c3bdaa6a1160288b6f0d17045cead to your computer and use it in GitHub Desktop.
Script to download large files from google drive using curl
#!/bin/bash
# Script to download large files from google drive using curl
# Source https://stackoverflow.com/a/38937732
# Edited by rama982
# Usage example: bash gdcurl.sh 1WPyPIX07W4diry8ZifQWZlPpDa4UWg2s cookies.txt
# google file ID
ggID=$1
# google url
ggURL='https://drive.google.com/uc?export=download'
# if file need to login before download, provide your own cookies.txt
[[ ! -z "$2" ]] && LOGIN="-b $2"
# get filename
filename="$(curl $LOGIN -sc /tmp/gcokie "${ggURL}&id=${ggID}" | grep -o '="uc-name.*</span>' | sed 's/.*">//;s/<.a> .*//')"
[ -z "$filename" ] && exit
echo "Filename: $filename"
# execute download
curl -Lb /tmp/gcokie "${ggURL}&confirm=t&id=${ggID}" -o "${filename}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment