Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save steinwaywhw/a4cd19cda655b8249d908261a62687f8 to your computer and use it in GitHub Desktop.

Select an option

Save steinwaywhw/a4cd19cda655b8249d908261a62687f8 to your computer and use it in GitHub Desktop.
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr 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 -
@Mr-Bossman
Copy link

I must admit that the awk based solution of @maxadamo seem to be the best and easiest. And also portable as it avoids seds x-platform issues.

I'm curious what you mean by " seds x-platform issues".

@antofthy
Copy link

antofthy commented Jan 16, 2026

@eabase

curl -s https://api.github.com/repos/NordicSemiconductor/nrf-udev/releases/latest | awk -F\" '/nrf-udev_1.*-all.deb/{print $(NF-1)}' | tail -1 | wget -i-

Why use BOTH "curl" and "wget". They both do the same thing, but few development environments have both.

"awk" with a field separator of the double quote is a nice solution, and works to pull out the specific architecture required. "sed", "grep", or many of the other general tools can also do the job.

But... I have said before, the final solution generally depends of the specific repo, the environments that is running the code to pull the latest release required. There is no one answer, which is what makes this discussion so interesting.

@eabase
Copy link

eabase commented Jan 16, 2026

@Mr-Bossman

I'm curious what you mean by " seds x-platform issues".

sed is not implemented equally across platforms (x-platform = "cross platform"), it also depends on local environment and if using POSIX. See sed switches for -R,-r,-E etc.. on different distros. It also depends on your bash and sh options via (set, shopt)...

@antofthy
Copy link

antofthy commented Jan 16, 2026

@eabase
sed is not implemented equally across platforms (x-platform = "cross platform")...
It also depends on your bash and sh options via (set, shopt)...

First I ever heard of bash and sh options effecting any command that isn't a builtin to bash and sh (apart from command parsing that is). I'm pretty good with shell (35+ years experience)... Please enlighten!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment