#!/bin/bash URL="ftp://ftp.gnu.org/gnu/nettle/" # Get version number from FTP server VERSION=$(curl -s --list-only "$URL" | grep -E '^nettle-[0-9]{1,}\.[0-9]{1,}(\.[0-9]{1,})?.tar.gz$' | cut -d '-' -f2 | sort -V | tail -n1) # Remove '.tar.gz' suffix from VERSION variable VERSION=${VERSION//.tar.gz/} echo "$VERSION"