Skip to content

Instantly share code, notes, and snippets.

@secvalve
Created May 25, 2016 00:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save secvalve/fbe41b7cc45812e386c6c8ea95075d3c to your computer and use it in GitHub Desktop.
Save secvalve/fbe41b7cc45812e386c6c8ea95075d3c to your computer and use it in GitHub Desktop.
A bash script that uses CURL to get a file in parts, ala axel. Usage: baxel numparts url eg ./baxel 3 http://www.google.com/robots.txt
#!/bin/bash
#$1 numparts, #$2 url
#Get length
TL=$(curl -sI $2 | grep Content-Length | awk '{printf "%d", $2}')
echo "$s is $TL Bytes Long”
#GetChunks
for i in `seq 0 $(( $1 - 1 ))`;
do
echo $(curl -r $(( i * (TL / $1) ))-$(( ( i + 1 ) * ( TL / $1 ) )) $2)
done
#if even get the last bit
if [ $(( TL % 2 )) = 1 ];
then echo $(curl -r -1 $2)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment