Download Google Drive Files with wget

DOWNLOAD GOOGLE DRIVE FILES WITH WGET OR CURL

https://www.matthuisman.nz/2019/01/download-google-drive-files-wget-curl.html

Note: Make sure the file has been shared ‘via link’ as the script does not authenticate you.

Small File (less than 100MB)

cd ~

export fileid=1yXsJq7TTMgUVXbOnCalyupESFN-tm2nc
export filename=matthuisman.jpg

## WGET ##
wget -O $filename 'https://docs.google.com/uc?export=download&id='$fileid

## CURL ##
curl -L -o $filename 'https://docs.google.com/uc?export=download&id='$fileid

Large File (more than 100MB)

cd ~

export fileid=1sNhrr2u6n48vb5xuOe8P9pTayojQoOc_
export filename=combian.rar

## WGET ##
wget --save-cookies cookies.txt 'https://docs.google.com/uc?export=download&id='$fileid -O- \
     | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p' > confirm.txt

wget --load-cookies cookies.txt -O $filename \
     'https://docs.google.com/uc?export=download&id='$fileid'&confirm='$(<confirm.txt)

## CURL ##
curl -L -c cookies.txt 'https://docs.google.com/uc?export=download&id='$fileid \
     | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p' > confirm.txt

curl -L -b cookies.txt -o $filename \
     'https://docs.google.com/uc?export=download&id='$fileid'&confirm='$(<confirm.txt)

rm -f confirm.txt cookies.txt