Created
January 9, 2017 14:28
-
-
Save larsbratholm/ec06c4d776ca2ef13368293ce71d6424 to your computer and use it in GitHub Desktop.
wget a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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