Skip to content

Instantly share code, notes, and snippets.

@caiofaustino
Created March 16, 2021 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caiofaustino/1c93708878e2088a6a33ad042d3c9ab3 to your computer and use it in GitHub Desktop.
Save caiofaustino/1c93708878e2088a6a33ad042d3c9ab3 to your computer and use it in GitHub Desktop.
Download Maven repository files recursively
#!/bin/bash
echo "Starting curl script"
echo ""
download_path=$1
echo "download_path: $download_path"
local_path=$2
echo "local_path: $local_path"
script_path="/your/script/path/get_repo.sh"
echo ""
curl_result=$(curl $download_path)
filter=$(echo $curl_result | tr ' ' '\n' | grep href=)
echo ""
for f in $filter; do
pattern="href="
path=$(echo $f | tr -d '"' | tr -d ':')
path=${path/$pattern/}
echo "Found: $path"
if [[ $path == *"."[a-z][a-z][a-z] ]]; then
echo "Downloading file: $download_path$path"
(cd $local_path && curl -O "$download_path$path")
else
echo "Creating folder at: $local_path$path"
mkdir -pv "$local_path/$path"
echo ""
echo "Starting script again..."
echo "New download path: $download_path$path"
echo "New local path: $local_path$path"
echo ""
$script_path "$download_path$path" "$local_path$path"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment