I use the github api to access existing server versions and tags in a bash script.
Here is a function like I use it in → nc-apps ← , for example:
github_api(){
local URL="https://api.github.com/repos/$1/$2?per_page=$3"
case $2 in
tags) curl -s "$URL" | jq -r '.[] | .name' | sed 's/^v//' | grep "^[0-9]\{1,2\}\.[0-9]\.[0-9]" | grep -iv a
;;
releases) curl -s "$URL" | jq -r '.[] | .tag_name' | sed 's/^v//' | grep "^[0-9]\{1,2\}\.[0-9]\.[0-9]" | grep -iv a
esac
}
Here is a sample output:
root@box:~# github_api "nextcloud/server" "releases" "10"
29.0.0rc1
28.0.4
27.1.8
26.0.13
These results can now be easily parsed for patterns. You don’t even need any knowledge of regular expressions, as this version can be divided into numbers.
I can explain all of this to you, but I feel a little strange because it’s explaining a language and doesn’t really belong here.
But I don’t want to leave you out in the cold like that. Therefore, here is a hand-picked series of sources from which you can familiarize yourself with all the techniques of bash and shell scripting.
- Bash Documentation: The official Bash documentation is an excellent source for detailed information on Bash commands, syntax, and functions. It’s available at GNU Bash manual - GNU Project - Free Software Foundation.
- Bash Guide at TLDP: The Bash Guide on The Linux Documentation Project (TLDP) provides a comprehensive introduction to Bash programming along with many practical examples. You can access it at http://tldp.org/LDP/abs/html/.
- Bash Academy: An interactive online platform offering free courses on Bash programming. It provides a blend of lessons and hands-on exercises. Visit https://guide.bash.academy/.
- Shell Programming at Wikibooks: The Shell Programming book at Wikibooks offers a solid introduction to shell scripting with plenty of examples and explanations. You can read it at https://en.wikibooks.org/wiki/Bash_Scripting.
- Bash Scripting Cheat Sheet at Devhints: Devhints offers a handy Bash scripting cheat sheet containing quick references to commonly used commands and syntax. You can find it at Bash scripting cheatsheet.
- Bash Scripting Tutorial at ShellCheck: ShellCheck provides a tutorial on Bash scripting along with a handy shell script analysis tool to improve script quality. Access it at https://www.shellcheck.net/.
- Bash Scripting Guide at Ryanstutorials: Ryanstutorials offers a comprehensive guide to Bash scripting with step-by-step explanations and practical examples. Explore it at Bash Scripting Tutorial - Ryans Tutorials.
and last but not least, the source of most of my knowledge, the man pages:
apropos . | xargs -n 1 man
Much and good luck,
ernolf