Skip to content

Instantly share code, notes, and snippets.

@contropist
Forked from vladalive/gdrive_download.md
Created December 18, 2019 14:54
Show Gist options
  • Save contropist/126857a24351604e9a49e25e94c2e400 to your computer and use it in GitHub Desktop.
Save contropist/126857a24351604e9a49e25e94c2e400 to your computer and use it in GitHub Desktop.
Download Google Drive files from linux terminal via wget

Setup:

  1. Add this code to your ~/.bash_aliases file.
function gdrive_download () {
  CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$1" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
  wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2
  rm -rf /tmp/cookies.txt
}
  1. Open new bash session.

Usage:

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