#!/bin/bash # Git repository REPO="git://sourceware.org/git/binutils-gdb.git" # Get tag name using 'git ls-remote' TAG_NAME=$(git ls-remote --exit-code --refs --tags --sort='v:refname' "$REPO" | grep -E "gdb-([0-9].*)-release" | tail -1 | cut -d'/' -f3) # Get version number from tag name VERSION=$(echo "$TAG_NAME" | cut -d'-' -f2) echo "$VERSION"