How to get the latest uploaded path from curl output?

I'm able to download the file successfully using the following curl command.

curl -u  ${UserName}:${Password}  -k ${URL} -o ~/response.txt

Example of directory contents and filenames from response.txt is

<a href="2.0.0-SNAPSHOT/">2.0.0-SNAPSHOT/</a>      05-Mar-2020 11:13    -
<a href="5.0.0-SNAPSHOT/">5.0.0-SNAPSHOT/</a>      06-Feb-2020 13:14    -
<a href="2.0.2-SNAPSHOT/">2.0.2-SNAPSHOT/</a>      06-Mar-2020 15:51    -
<a href="2.0.1-SNAPSHOT/">2.0.1-SNAPSHOT/</a>      05-Mar-2020 17:39    -

So, I would like to automate the whole process to find out the latest folder name from it? I tried using

sort 

using column

3,4 

names but still not able to figure it out if this is the best solution as I don't know if, in long run whether column 3 and 4 will be right one to provide the latest folder?
can anyone suggest me how to get the latest

SNAPSHOT 

from here best possible way?

PS: Now i tested with some other values sort is definitely not the right one.

Hi
You can use the GNU extension - the 'asorti' function in 'awk'

awk -F' *|-' -vm="$(LC_ALL=C locale ab_alt_mon)" '
BEGIN   {for(n=split(m, M, ";"); n; n--) Mm[M[n]]=n}
        {A[$7 Mm[$6] $5 $8]=$0}
END     {n=asorti(A, D); print A[D[n]]}
' response.txt

but this way it seems easier and faster

awk -F' *|-' -vm="$(LC_ALL=C locale ab_alt_mon)" '
BEGIN   {for(n=split(m, M, ";"); n; n--) Mm[M[n]]=n}
        {print $7 Mm[$6] $5 $8 " " $0}
' response.txt | sort | tail -1 | cut -d' ' -f2-

--- Post updated at 15:54 ---

Something I did not think, if only the last snapshot is needed it will be easier

awk -F' *|-' -vm="$(LC_ALL=C locale ab_alt_mon)" '
BEGIN   {for(n=split(m, M, ";"); n; n--) Mm[M[n]]=n}
        {f=$7 Mm[$6] $5 $8; if(f>str) {str=f; st=$0}}
END     {print st}
' response.txt
1 Like