Skip to content

Instantly share code, notes, and snippets.

@larsbratholm
Created January 9, 2017 14:28
Show Gist options
  • Save larsbratholm/ec06c4d776ca2ef13368293ce71d6424 to your computer and use it in GitHub Desktop.
Save larsbratholm/ec06c4d776ca2ef13368293ce71d6424 to your computer and use it in GitHub Desktop.
wget a directory
#!/bin/bash
# remove http:// etc
SUBSTRING=$(cut -d. -f2- <<< "$1")
# remove last slash if present
if [ "${SUBSTRING: -1}" = "/" ];then
SUBSTRING="${SUBSTRING%?}"
fi
# count subdirectories
NCUT=$(grep -o "/" <<< "$SUBSTRING" | wc -l)
wget -r -nH --cut-dirs="$NCUT" -np -R index.html* -e robots=off "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment