#!/bin/sh usage="Usage: $0 filename [urlroot]" test $# -eq 0 && echo "$usage" && exit 1 test $# -gt 2 && echo "$usage" && exit 1 imgurls=`cat "$1" \ | awk -F \( '/!\[[^\]]*\]\([^\)]*\)/ {print $2}' \ | sed 's/)\]$//' \ | awk '{print $1}'` for i in $imgurls; do echo "$i" | grep -q '//' test $? -ne 0 && i="${2}${i}" wget "$i" done