~smlavine/scripts

ref: 6b6b353a93f3267f6ada9e9d117b2aac3a5d0fa2 scripts/src/download -rwxr-xr-x 626 bytes
6b6b353aSebastian LaVine src/download: Add recursive functionality 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# Copyright (c) 2021 Sebastian LaVine <mail@smlavine.com
# Licensed under the MIT license. See MIT.txt for details.
#
# File:        download
# Description: Downloads the given URLs.
# Options:     -r        Download the URL recursively using wget. User
#                        discretion is advised.
# Arguments:   URLs to download.

usage()
{
	echo "USAGE: download [-r] [url]..."
}

while getopts "rh" o; do
	case "$o" in
		r) recurse=1 ;;
		*) usage; exit ;;
	esac
done

shift $((OPTIND - 1))

for file in "$@"; do
	if [ "$recurse" ]; then
		wget -r -l 0 -e robots=off "$file"
	else
		curl -LO "$file"
	fi
done