Created
April 24, 2014 22:28
-
-
Save alexdantas/11271729 to your computer and use it in GitHub Desktop.
Downloads all files with a specified extension from a website
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
#!/usr/bin/bash | |
# | |
# wget-all: gets all files from a specified file extension | |
# on a remote host | |
function usage() { | |
echo 'Usage:' | |
echo ' $ wget-all.sh <remote-host> <filename-extension>' | |
echo | |
echo 'Example:' | |
echo ' $ wget-all.sh alexdantas.net/tmp png' | |
} | |
if [[ -z "$@" ]] | |
then | |
usage | |
exit -1 | |
fi | |
if [[ -z "$2" ]] | |
then | |
echo 'No file extension specified' | |
usage | |
exit -2 | |
fi | |
# Thanks, http://stackoverflow.com/a/5045370 | |
CURRENT_DIR="-nH --cut-dirs=1" | |
wget "$1" -r -l1 --no-parent $CURRENT_DIR -A."$2" | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great minds think alike https://github.com/thomhastings/os-scripts/blob/master/wgetall.sh