#!/bin/bash tags="$(git ls-remote --tags https://github.com/BOINC/boinc "client_release/*.*/*.*.*" | \ grep -v "\^{}\$" | \ sed "s/^\S\+\s\+.*\/client_release\/[^/]*\/\(.*\)\$/\1/" | \ sort -n)" main="$(echo -e "${tags}" | \ cut -d . -f 1 | \ sort -n | \ tail -n1)" tags="$(echo -e "${tags}" | \ grep "^${main}\." | \ sed "s/^[^.]\+\.//")" sub="$(echo -e "${tags}" | \ cut -d . -f 1 | \ sort -n | \ tail -n1)" tags="$(echo -e "${tags}" | \ grep "^${sub}\." | \ sed "s/^[^.]\+\.//")" subsub="$(echo -e "${tags}" | \ sort -n | \ tail -n1)" echo "${main}.${sub}.${subsub}"