I am writing a code in Shell Script to download the source code of the latest updated version of PostgreSQL by checking the link to the current version automatically.
So based on this I did the following:
I created the variable URL_PKG
URL_PG=${URL_PG:-https://ftp.postgresql.org/pub/source}
The current version of PostgreSQL is 10.3
So I created the following variable:
bash-4.4$ echo SVERSION=${SVERSION:-$(lynx --dump ${URL_PG}|awk -F'/' '/v[0-50]/ {print $1}'|cut -c8-12)}
It returns me this below:
SVERSION=1.08 1.09 10.0 10.1 10.2 10.3 ttps: ttps: ttps: ttps: ttps: ttps:
How do I create the command to get the highest value of the folder inside the link so if I run it get the name of the folder "v10.3" and successively if the version is 10.4?
then give the following output:
bash-4.4$ echo URL_DB=${URL_DB:-${URL_PG}/${SVERSION}}
URL_DB=https://ftp.postgresql.org/pub/source/v10.3