Skip to content

Instantly share code, notes, and snippets.

@a-gu
Last active October 22, 2022 20:14
Show Gist options
  • Save a-gu/0896650fab52928a69e49fbd6307adcf to your computer and use it in GitHub Desktop.
Save a-gu/0896650fab52928a69e49fbd6307adcf to your computer and use it in GitHub Desktop.
Downloads the lateset PaperMC jarfile (using messy gawk JSON "parsing")
#!/usr/bin/env bash
base='https://papermc.io/api/v1/paper'
version=$(curl -s $base | gawk 'match($0, /"versions"\s*:\s*\[\s*"([^"]+)/, a) {print a[1]}')
build=$(curl -s "${base}/${version}" | awk '{print gensub(/^.+"builds"\s*:\s*{\s*"latest"\s*:\s*"([^"]+)".+$/, "\\1", "g");}')
url="${base}/${version}/${build}/download"
curl -JLO $url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment