Skip to content

Instantly share code, notes, and snippets.

@giabao
Last active May 23, 2016 15:22
Show Gist options
  • Select an option

  • Save giabao/8414868 to your computer and use it in GitHub Desktop.

Select an option

Save giabao/8414868 to your computer and use it in GitHub Desktop.
Use aria2c to download file1. add params (to speedup downloading): -s16 -x16 -k1M2. add --check-certificate=false3. simulate -o option of curl: dl -o /dir/file url will download file to /dir/file insteads of ./dir/file_______Install:1. apt-get install aria2c2. Download & chmod a+x /usr/bin/dl
#!/bin/bash
#Use aria2c to download file
#1. add params (to speedup downloading): -s16 -x16 -k1M
#2. add --check-certificate=false --file-allocation=falloc
# see http://aria2.sourceforge.net/manual/en/html/aria2c.html#cmdoption--file-allocation
#3. simulate -o option of curl:
# dl -o /dir/file url
# will download file to /dir/file insteads of ./dir/file
args=" $@"
# parse -o
pat=".*\(\s-o\s*[^ ]*\).*"
val=`expr match "$args" "$pat"`
#parse --out=
if [ ! "$val" ]; then
pat=".*\(\s--out=\s*[^ ]*\).*"
val=`expr match "$args" "$pat"`
fi
if [ "$val" ]; then
args="-d /$args"
fi
args="-s16 -x16 -k1M --check-certificate=false --file-allocation=falloc $args"
exec /usr/bin/aria2c $args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment