Skip to content

Instantly share code, notes, and snippets.

@Pk13055
Created December 27, 2018 17:59
Show Gist options
  • Save Pk13055/dce290dc9cf1a9aaa68713edb1c2571f to your computer and use it in GitHub Desktop.
Save Pk13055/dce290dc9cf1a9aaa68713edb1c2571f to your computer and use it in GitHub Desktop.
Parallel curl version
#!/bin/bash
url=$1
file_size=`curl -sI "$1" | grep "Content-Length" | head -n 1 | cut -d ':' -f 2 | cut -d " " -f 2 | sed "s|\r||g"`
length_of_each_part=`echo $((file_size/10))`
start=0
end=$length_of_each_part
for i in {1..10}
do
curl -s --range $start-$end -o /tmp/movie.part."$i" "$url" &
start=$((end+1))
end=$((end+length_of_each_part))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment