Home > bash, coding > Retrieve “last modified” timestamp of web resource in UTC seconds

Retrieve “last modified” timestamp of web resource in UTC seconds

This command line assumes that “${url}” is the URL of the web resource:

curl -s -I "${url}" | grep 'Last-Modified:' | cut -c 16- | date -f - +'%s'

It can be useful to check the freshness of a download URL before a GET request.

You could compare the result to the last-modified timestamp of a local file and only download the remote file if it is newer than the existing local one.

Advertisements
Categories: bash, coding Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: