Skip to content

Instantly share code, notes, and snippets.

@d3banjan
Last active September 15, 2018 09:05
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 d3banjan/9b8d13d502e94773c1e3d3b52058a6a8 to your computer and use it in GitHub Desktop.
Save d3banjan/9b8d13d502e94773c1e3d3b52058a6a8 to your computer and use it in GitHub Desktop.
download large files in chunks
#! /bin/bash
LARGE_FILE_URL="http://vatic2.stanford.edu/stanford_campus_dataset.zip"
APPROX_SIZE=`echo "69*1024*1024*1024"| bc`
CHUNKSIZE=`echo "128*1024*1024" | bc`
NCHUNKS=`echo "1+ (($APPROX_SIZE)/($CHUNKSIZE))" | bc`
STARTCHUNK="1"
OUTDIR="/media/debanjan/xxx"
OUTFILE="stanford_campus_dataset.zip"
SLEEP_INTERVAL="10"
for ichunk in $(seq -f '%05g' 1 $NCHUNKS);
do
from=`echo "($ichunk-1)*$CHUNKSIZE" | bc`
to=`echo "$ichunk*$CHUNKSIZE - 1"| bc`
curl --range "$from-$to" "$LARGE_FILE_URL" -o "$OUTDIR/$OUTFILE.$ichunk"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment