diff options
-rwxr-xr-x | buff-di-wuff | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/buff-di-wuff b/buff-di-wuff index bcd1526..c86965f 100755 --- a/buff-di-wuff +++ b/buff-di-wuff @@ -12,34 +12,25 @@ mkdir -p \ grep '^[^#]' "$(dirname "$0")/downloads.list" | \ while read -r url urlDir; do - if [ -n "${urlDir}" ]; then - urlFile=$( - printf '%s\n' "${url}" | \ - sed ' - s|\.|\.|g - s|*|.*|g - ' - ) - wget --no-check-certificate -O - "${urlDir}" 2> /dev/null | \ - tr '"<>' '\n' | \ - grep "^${urlFile}\$" | \ - sort -u - elif echo "${url}" | \ - grep -q '\*[^/]*$'; then - urlDir=$( - printf '%s\n' "${url}" | \ - sed 's|/[^/]*$|/|' - ) + if [ -n "${urlDir}" ] || \ + echo "${url}" | \ + grep -q '\*[^/]*$'; then + if [ -z "${urlDir}" ]; then + urlDir=$( + printf '%s\n' "${url}" | \ + sed 's|/[^/]*$|/|' + ) + fi urlFile=$( printf '%s\n' "${url}" | \ sed ' s|^.*/|| - s|\.|\.|g + s|\.|\\.|g s|*|.*|g ' ) wget --no-check-certificate -O - "${urlDir}" 2> /dev/null | \ - tr '"<>' '\n' | \ + tr '"<>/' '\n' | \ grep "^${urlFile}\$" | \ sort -u | \ xargs -r printf "${urlDir}%s\n" |