As an alternative you can use wget (which is not quite as portable):
curl -sS https://sourceforge.net/projects/geoserver/files/GeoServer/2.10.1/extensions/ | sed -rn 's_^.*<a href="(https://sourceforge.net/projects/geoserver/files/.*/download)"$_\1_p' | wget -i - --trust-server-names
- The curl simply retrieves the html page containing the list of files.
- The sed command finds the urls and strips them out.
- The wget then downloads the list of files.
It might be easier to understand by putting it into a (somewhat reusable) script called:
#!/bin/bash
if [[ -z "$1" || -z "$2" || -n "$3" && "$3" != 'test' ]]; then
echo "Usage: dlist <htmlsource> <regexp> [test]\n <htmlsource> can be a local file or url\n <regex> is the inner part to \"s_^.*${regex}.*\$_\1_p\"\n [test] is the option to show the files to be download"
else
regex="s_^.*$2.*\$_\1_p"
if [[ "$3" == 'test' ]]; then
echo "Using regex $regex:"
regex="s_^.*$2.*\$_ \1_p"
if [[ "$1" == http* ]]; then
curl -sS "$1" | sed -rn "$regex"
else
sed -rn "$regex" "$1"
fi
elif [[ "$1" == http* ]]; then
curl -sS '$1' | sed -rn "$regex" | wget -i - --trust-server-names
else
sed -rn "$regex" "$1" | wget -i - --trust-server-names
fi
fi
which can be called with (assuming it is named dlist):
dlist https://sourceforge.net/projects/geoserver/files/GeoServer/2.10.1/extensions/ '<a href="(https://sourceforge.net/projects/geoserver/files/.*/download)"'
The first option is simply the url of the list of files you want: you can also save the file and specify that on the commandline.
Then if you view source on the file list web page (or the copy you downloaded), scroll through and find the list of links which will give you the url to search for. When crafting the regex, surround the part of the url you want with brackets (starting from just before the http) and replace the part that changes with all the urls with .*
The second option is the simplified regex crafted above.
wget
has builtin functionality to follow/expand selectable web links that handles many cases like this, but I haven't tested this one specifically. See the man page starting at Recursive Retrieval Options or the info at the equivalent topics under Invoking and addtional discussion at Following Links