Skip to content

Instantly share code, notes, and snippets.

@vithalreddy
Last active September 17, 2019 08:20
Show Gist options
  • Save vithalreddy/ea807b3e7123b5ff2e8b56fbd016027d to your computer and use it in GitHub Desktop.
Save vithalreddy/ea807b3e7123b5ff2e8b56fbd016027d to your computer and use it in GitHub Desktop.
Shell Script To Download Google Drive Files from terminal
#!/bin/bash
read -p "Enter File Id: " fileid
read -e -p "Enter File Dir: " "path_to_download_dir" dir #replce with your download dir path ~/Downloads
cd ~/$dir
echo "File will be downloaded in dir: ~/{$dir}"
curl -c ./$fileid -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./$fileid "https://drive.google.com/uc?export=download&confirm=`awk \
'/download/ {print $NF}' \
./$fileid`&id=${fileid}" -O -J -L
if [ -f ./$fileid ] ; then
rm -rf ./$fileid
echo "cookie file deleted successfully"
fi
echo "File downloaded in dir: ~/{$dir}"
@vithalreddy
Copy link
Author

To Make Script Exec,
well you can make it by doing as

chmod +x gd.sh
so it will execute when you call it will

./gd.sh

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