Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@vladalive

This comment has been minimized.

Copy link
Owner Author

commented May 16, 2019

created this gist from the original one:
https://gist.github.com/iamtekeste/3cdfd0366ebfd2c0d805

@crazyapril

This comment has been minimized.

Copy link

commented Jun 3, 2019

Works for me. Thanks!

@AbnerCode

This comment has been minimized.

Copy link

commented Sep 18, 2019

why it is not work ?
the error information is the bash command not found

@vladalive

This comment has been minimized.

Copy link
Owner Author

commented Sep 18, 2019

@AbnerCode can you please give more details about your error? what's the console output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.