Downloading files based on most recent date and timestamp?

This question regards to curl or wget. I would like to download the most recent file in a folder matching to a pattern e.g. FILENAME[0-9].txt.

Example: If there are 4 files in a remote directory:

FILENAME1.txt with Date/Time 2017-03-17 10:00
FILENAME2.txt 2017-03-17 11:00
FILENAME3.txt 2017-03-17 09:00
HOWTO.PDF 2017-03-17 09:00

curl (or wget) should only grab FILENAME2.txt
Is there a handy shell-script somewhere?
Thanks in advance!

okay I am downloading whole folder and trying to get the last modified file with find
I am close but still need help from a unix/linux crack:

find /folder -printf '%p
’ | sort | tail -1 | cat > /folder/filename.txt

does that job - but cat result is just the filename and not the content… what I am missing?

Why not use that result and turn around and download THAT file?

cause wget uses parameters and not pipe streams

I’m using stat to look file modification dates:

Dim cmd As String = "stat -c '%Y %n' ~/Documents/data/*.pdf"

Jukka

got it… thank you all

cat $(find /folder -printf '%p
’ | sort | tail -1) > /folder/filename.txt