How do I use wget to download the latest stable version of RL?

How do I use wget to download the latest stable version(minimal) of RL?
I want to do this from a bash script only…

Serg

Just did this now for you:

#!/bin/bash
#
# Get latest Rocky ISO

# Variables
URL=https://download.rockylinux.org/pub/rocky/8/isos/x86_64/
ISO=`curl -s ${URL} | grep -i minimal | egrep -iv "manifest|torrent" | cut -f2 -d ">" | sed 's/<\/a//'`

# Download file
wget ${URL}${ISO}

the URL must include the slash at the end so that the curl command used for the ISO variable gets the directory listing which comes in html format. We are then grepping that to filter for the minimal iso, and then removing manifest and torrent from the list. We then filter out the a href= field and remove the ending </a> to leave us with the filename.

We then combine the URL and ISO variables to download the file. I’m sure there are other ways also. Obviously this is based on the fact that the download URL only has one version of Rocky listed, which is how it is right now. This might or might not change in the future, but then you would just modify the code accordingly to deal with that. But for now it works fine.

3 Likes

@infrastructure - I would suggest to put links into the iso directory:

Rocky-latest-x86_64-minimal.iso → Rocky-8.5-x86_64-minimal.iso

However, if you had already downloaded a “Rocky-latest-x86_64-minimal.iso”, then you could not tell from that filename whether it still is the latest.