- Use
curl
to get the JSON response for the latest release - Use
grep
to find the line containing file URL - Use
cut
andtr
to extract the URL - Use
wget
to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
@majick777 That only works for projects that post assets with simple filenames that don't have any changing version data in the asset name itself. Some projects do that, but not all can be downloaded that way and while it makes this easy doing that makes other things hard (like keeping multiple versions of something in a directory). Hence these solutions are still useful in 2021. If the project you are downloading from doesn't have version info in the asset name by all means use those "latest" links.
As for the proliferation of comments here:
grep
s and acut
could be simplified to a singlegrep
if you pay attention to the URL scheme to match. Many examples above make the mistake of usingxargs
, then only handling one possible output. These will fail badly if more than one match is found.jq
and withgrep
above to illustrate how different tooling could be used to advantage. Likewise swappingwget -qi
andcurl -fsLJO
can be a matter of system tooling choice.Before posting more, please seriously consider whether your solution offers something more in the way of a better implementation or more explanation than existing options. If you just copied and tweaked an existing one to match some other project URL scheme, please refrain since that won't add anything.