1#! /bin/bash 2 3# get a list of urls and corresponding output file names, then parse them to wget 4 5args=("$@") 6list=${args[0]} 7 8if[[$list==""]] 9then 10printf"\n\x1b[31mWrong number of arguments\x1b[0m\n\n" 11printf"Usage: nameget LIST [DESTINATION] [ARGS]\nwhere LIST is a text file of format [url] [name] (one pair per line)\n[DESTINATION] is a path appended to the start of each [name] in LIST\n[ARGS] is passed directly to wget" 12exit1 13fi 14 15if[[-d${args[1]}]];then# check if args[2] is [DESTINATION] or [ARGS] 16 outdir=${args[1]} 17if[[ !$outdir=~ /$ ]];then# check if [DESTINATION] has a trailing / 18 outdir=$outdir/ 19fi 20shift2 21else 22shift1 23fi 24 25otherargs=$@ # set aside remaining arguments for passing to wget 26 27whileread -r url filename tail;do 28 wget --cut-dirs=100-r -np -nc --accept -e robots=off -O"$outdir$filename""$url"$otherargs 29done<$list