- 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 -
Fair.
A general 1-liner, even to a specific git repo, is quite difficult to achieve.
But a 1-liner that can be easily adapted to a number of cases is a different thing and is something much easier to do.
The type of things you can look for here and in any other question-and-answers web sites.
The original 1st post here, was already a Unix shell-based solution, not a question, using 5 different commands, none aimed at JSON parsing and with inexplicably replicated functions between
wget
andcurl
. If the output from GitHub were moved to "compact JSON" (no newlines at all) by GitHub itself, then most of those JSON-unaware scripts would stop working.The original solution, as most of the subsequent replies, has likely been created by merging 2 different sources.
I have shared my (rather limited) knowledge about scripting to get a simple, minimal and reliable 1-liner that can be easily adapted to a large number of cases.
It only uses 2 tools (
wget
andjq
) aimed exactly at their goals (downloading via HTTP and reliably parsing JSON strings).This is according to the Unix command line art of simplicity, IMHO.
"Life is really simple, but we insist on making it complicated."
-- Confucius
"It is not a daily increase, but a daily decrease. Hack away at the inessentials."
-- Bruce Lee
"If you can't explain it to a six year old, you don't understand it yourself."
-- Albert Einstein