Last active
July 26, 2021 18:10
-
-
Save Kabongosalomon/86333dad37b475d8eb64543ddfce4163 to your computer and use it in GitHub Desktop.
A script to download content from a google drive link. How to use : bash gdrive.sh <comple-google-driv-link>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
gfile=$1 | |
# gfile_ID=(${gfile//// }) | |
gfile_ID=$1 | |
# f1 = ${f1_[0]} | |
echo "Make sure you extract the file ID from the google link" | |
echo "e.g. from https://drive.google.com/open?id=1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ extract 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ" | |
echo "The code then is run as follow : bash gdrive.sh 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ" | |
# echo ${gfile_ID[-2]} | |
echo ${gfile_ID} | |
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='${gfile_ID} -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=${gfile_ID}" -O data && rm -rf /tmp/cookies.txt && unzip data && rm data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"Make sure you extract the file ID from the google link"
"e.g. from https://drive.google.com/open?id=1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ extract 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ"
"The code then is run as follow:
bash gdrive.sh 1kKWoV0QCbeIuFt85beQgJ4v0lujaXobJ