Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SerhatTeker/42f6d3807cf17d0b7221886648b6b267 to your computer and use it in GitHub Desktop.
Save SerhatTeker/42f6d3807cf17d0b7221886648b6b267 to your computer and use it in GitHub Desktop.
shell.func-download-all-files-from-any-GITHUB-GIST-URL {updated to *new* gist}
# Usage Example: $ ddl-gist 'https://gist.github.com/4137843' ~/Downloads/gists
# save the gist files at that URL in ~/Downloads/gists
##
ddl_gist(){
if [ $# -ne 2 ];
then
echo 'Failed. Syntax: $> ddl-gist GITHUB_GIST_URL DOWNLOAD_PATH'
return
fi
gist_url=$1
download_path=$2
echo '[*] Getting all GIST File URLs from '$gist_url
gists=`curl -ksL -H 'User-Agent: Mozilla/5.0' $gist_url | grep '<a\ .*href=".*/raw/' | sed 's/.*a\ .*href="//' | sed 's/".*//'`
echo '[*] Downloading all files'
for lines in `echo $gists | xargs -L1`;
do
if [ ! -z $lines ];
then
echo $lines
gistfile=`echo $lines | sed 's/.*\///'`
save_as=$download_path"/"$gistfile
echo "Downloading URL: https://gist.github.com"$lines
echo "to "$save_as"....."
wget -c -O $save_as "https://gist.github.com"$lines
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment