Skip to content

Instantly share code, notes, and snippets.

@themegabyte
Last active May 31, 2020 19:14
Show Gist options
  • Save themegabyte/d8bf9bb5cb3f061268fe120e0f71d043 to your computer and use it in GitHub Desktop.
Save themegabyte/d8bf9bb5cb3f061268fe120e0f71d043 to your computer and use it in GitHub Desktop.

Add this to your ./bashaliases or ./bashrc file. You can also enter as a one time on your bash terminal

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
}

Usage:

gdrive_download Google_drive_file_id filename.ext

Explantion:

Google_drive_file_id: the id is as below, after d/ and before /edit

Example: https://drive.google.com/file/d/1yB4LvoPJG7KrF65FlvtG8kDm-uG-6781/edit

id: 1yB4LvoPJG7KrF65FlvtG8kDm-uG-6781

Credits: @vladalive

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