#!/bin/bash URL="https://www.gnu.org/software/binutils/" # Get version number VERSION=$(curl -s -L "$URL" | grep 'The latest release of GNU binutils is ' | grep -o -E '[0-9]{1,}\.[0-9]{1,}(\.[0-9]{1,})?') # Append '.0' if patch number is missing DOT_COUNT=`tr -dc '.' <<< "$VERSION" | awk '{ print length; }'` if [ $DOT_COUNT -eq 1 ]; then VERSION="${VERSION}.0" fi echo "$VERSION"