Skip to content

Instantly share code, notes, and snippets.

@lacek
Created April 27, 2020 13:31
Show Gist options
  • Save lacek/1f38321d2d713d4686430296036d6e04 to your computer and use it in GitHub Desktop.
Save lacek/1f38321d2d713d4686430296036d6e04 to your computer and use it in GitHub Desktop.
Shell script for Google Drive download
#!/bin/sh
FILE_ID=$1
DEST=$2
if [ -z "$FILE_ID" -o -z "$DEST" ]; then
>2 echo "USAGE: sh $0 <FILE_ID> <DEST>"
exit 1
fi
cookie=$(mktemp -ut gdown.XXXXXX)
trap "rm -rf $cookie" 0
set -e
curl -c "$cookie" -sL "https://drive.google.com/uc?export=download&id=$FILE_ID" > /dev/null
confirm=$(awk '/download/ {print $NF}' "$cookie")
curl -Lb "$cookie" "https://drive.google.com/uc?export=download&id=$FILE_ID&confirm=$confirm" -o "$DEST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment