Skip to content

Instantly share code, notes, and snippets.

@secvalve
Last active May 25, 2016 02:30
Show Gist options
  • Save secvalve/146344788627bea58d386700685ab525 to your computer and use it in GitHub Desktop.
Save secvalve/146344788627bea58d386700685ab525 to your computer and use it in GitHub Desktop.
A bash script that uses CURL to get a file in parts, ala axel. Paralellised version of baxel https://gist.github.com/secvalve/fbe41b7cc45812e386c6c8ea95075d3c. Usage: parabaxel numparts url eg ./parabaxel 3 http://www.google.com/robots.txt robots.txt
#!/bin/bash
#$1 numparts, #$2 url, #$3 outfile
#Get total length
TL=$(curl -sI $2 | grep Content-Length | awk '{printf "%d", $2}')
echo "$s is $TL Bytes Long"
let CHUNKSIZE=$(( TL / $1 ));
parallel -k curl -s -r {} $2 ::: $(for i in `seq -f "%.0f" 0 $CHUNKSIZE $(( $TL - $CHUNKSIZE ))`; do echo "$i-`expr $i + $CHUNKSIZE`"; done) #> $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment