The easiest way to do it is probably with curl
, using the -z
/--time-cond
option:
(HTTP/FTP) Request a file that has been modified later than the given time and date, or one that has been modified before that time. The can be all sorts of date strings or if it doesn't match any internal ones, it is taken as a filename and tries to get the modification date (mtime) from instead. See the curl_getdate(3) man pages for date expression details.
The accepted date formats are specified in curl_getdate
docs, but it suffices to say the usual English-natural RFC-822 format is supported, which is also supported in date
util via -R
/--rfc-2822
option.
We can calculate the date/time of the cut-off timestamp 24 hour ago with a relative date
string:
$ date -R -d '24 hours ago'
Mon, 25 Sep 2017 17:30:49 +0200
and supply that value to curl
:
curl 'ftp://server/file' --time-cond "$(date -R -d '24 hour ago')"
To save the output directly to a local file (and not output it to stdout), use the --output filename
option, and to suppress the progress output, use the -s
option.