Just for simplicity, here is a compilation of existing (ideal) answers from @ihorko and @ JanThomรค, which uses curl. Of course, another option is available, but here is a fully functional answer.
Use curl with the -I option:
-I, --head
(HTTP / FTP / FILE) Retrieve only the HTTP header! HTTP servers have a HEAD command, which is used to get nothing but the title of a document. When used in an FTP or FILE file, the curl displays only the file size and the time of the last modification.
Also, the -s is nice here:
-s, --silent
Quiet or calm mode. Do not show progress indicators or error messages. Makes twisting dumb. It will still output the data you request, potentially even to the terminal / stdout, unless you redirect it.
Therefore, something like this will do the trick:
curl -sI http://foo.com/bar.zip | grep 'Last-Modified' | cut -d' ' -f 2-
Benoit duffez
source share