Last active
May 6, 2024 04:41
-
-
Save moqmar/cc077e25e70f96c6da6f449cdb1b563c to your computer and use it in GitHub Desktop.
Get the latest release download from GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repo=sharkdb/fd | |
file=0 # use the first file | |
# with jq (recommended if available) | |
wget https://api.github.com/repos/${repo}/releases/latest -qO- | jq -r ".assets[${file}].browser_download_url" | |
# - or - | |
curl https://api.github.com/repos/${repo}/releases/latest -so- | jq -r ".assets[${file}].browser_download_url" | |
file=$(($file + 1)) # WARNING: sed uses 1-based indices! | |
# with grep/sed (might fail in the future for one reason or another, but works on almost every system out-of-the-box) | |
wget https://api.github.com/repos/${repo}/releases/latest -qO- | grep -oP '^\s*"browser_download_url":\s*"\K.*(?=",?$)' | sed "${file}q;d" | |
# - or - | |
curl https://api.github.com/repos/${repo}/releases/latest -so- | grep -oP '^\s*"browser_download_url":\s*"\K.*(?=",?$)' | sed "${file}q;d" | |
# Example for downloading the latest release: | |
wget `wget https://api.github.com/repos/${repo}/releases/latest -qO- | grep -oP '^\s*"browser_download_url":\s*"\K.*(?=",?$)' | sed "${file}q;d"` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment