-
-
Save bonelifer/22e8ef5acf79075a9766d7b4ac1df0ae to your computer and use it in GitHub Desktop.
Get the latest release download from GitHub
This file contains 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