From 80e575c391e81ad389da36e50a3612b887c98a6a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 5 Sep 2018 12:51:34 +0200 Subject: buff-di-wuff: better url matching --- buff-di-wuff | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/buff-di-wuff b/buff-di-wuff index 7cbe7cc..822a15d 100755 --- a/buff-di-wuff +++ b/buff-di-wuff @@ -21,20 +21,28 @@ grep '^[^#]' "$(dirname "$0")/downloads.list" | \ sed 's|/[^/]*$|/|' ) urlPrefix="${urlDir}" + urlFile="${url##*/}" + spacer='/' else - urlPrefix="${url%/*}/" + urlPrefix=$( + printf '%s\n' "${url}" | \ + sed ' + s,\([^/]/\)[^/].*$,\1, + ' + ) + urlFile="/${url#*//*/}" + spacer='' fi urlFile=$( - printf '%s\n' "${url}" | \ + printf '%s\n' "${urlFile}" | \ sed ' - s|^.*/|| s|\.|\\.|g s|*|.*|g ' ) wget --no-check-certificate -O - "${urlDir}" 2> /dev/null | \ - tr '"<>/' '\n' | \ - grep "^${urlFile}\$" | \ + tr '"<>'"${spacer}" '\n' | \ + grep '\(^\|/\)'"${urlFile}\$" | \ sort -u | \ xargs -r printf "${urlPrefix}%s\n" else -- cgit v1.2.3-70-g09d2