I've been trying to make a script and in this script I would like to update the folder name and a bunch of other things using a variable.

the folder i create is going to be called the latest version release name it has on github.

content=$(curl -s -L https://github.com/FAForever/client/releases)
fl=tr '\n' ' ' < $content | grep -E "^<div class=\"release-title\">.*</div>$"
echo $fl

s=$(curl -s https://github.com/FAForever/client/releases | grep "div class='release-title'")
echo "$s"

I've looked all over the web for this and noone does this specific setup (source curl/ output shell var)

all have some sort of file input or output or other and I can't make use of their solutions.

what is the correct syntax in shell to grab only one class' content and store it in a shell variable?

Thank you.


the github API https://api.github.com/ returns json which is can be nicely crunched with the command line tool jq

What do you need ? a list of releases ? ... try this

curl https://api.github.com/repos/FAForever/client/releases | jq .[].tag_name

which gives you output

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  107k  100  107k    0     0   314k      0 --:--:-- --:--:-- --:--:--  314k

if you say "Just show me the latest" then issue

sudo apt-get install jq

curl --silent  https://api.github.com/repos/FAForever/client/releases | jq .[].tag_name|sort -n|tail -1

with output


now to bundle into a shell script vi show_latest.sh


latest_release=$(curl --silent  https://api.github.com/repos/FAForever/client/releases | jq .[].tag_name|sort -n|tail -1)

echo latest_release $latest_release

which generates output

latest_release "0.12.0-pre2"
  • that's very good although i need it to be something that is preinstalled in ubuntu. right now i get "jq not installed" – tatsu Dec 21 '16 at 18:56
  • now it shows shell variable populated with answer – Scott Stensland Dec 21 '16 at 19:41

Same as Scott's answer but use Python instead.

curl https://api.github.com/repos/FAForever/client/releases | python -c 'import sys,json; print "\n".join(map(lambda x: x["tag_name"],json.load(sys.stdin)))'

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.