Thursday·25·November·2010
Useful but Unknown Unix Commandline Options: touch -d //at 20:42 //by abe
You may wonder how I manage to write one “Useful but Unknown Unix Something” blog posting per day. Well, I don’t. I write them in bursts, but don’t want to flood Planet Debian and Planet Symlink with more than one such posting a day.
The first bunch of postings were mostly slides (or part of a slide plus what I tell while showing the slide) from my Unknown but Useful Unix Tools talk and written somewhen last week. And this blog posting and yesterday’s blog posting were written in a row, too.
What does that have to do with Unix commandline tools? Well I use Blosxom as blogging engine and it’s based on simple text files lounging around in some directories, and the last modification time stamp is the posting’s date – which is cached after first time seen by the entries_index plugin so that I can fix typos without resetting the posting’s release date. Postings with a modification date in the future won’t be shown before that time.
So how do you set the last modification date to a date in the future? With “touch” from GNU Coreutils of course. Like “date”, “touch” also knows the option “-d” to explicity set a date and time instead of using the current date and time.
Now in my humble opinion the cool feature is that you can easily describe dates by giving touch values like “now + 1 hour”, “12:00 tomorrow” or so:
$ touch bla $ ls -l total 0 -rw-r--r-- 1 abe abe 0 2010-11-23 22:59 bla $ touch -d 'now + 1 day + 23 hours - 42 minutes' bla $ ls -l total 0 -rw-r--r-- 1 abe abe 0 2010-11-25 21:17 bla $
To see all the possibilities you have to describe relative dates with “touch”, “date”, and maybe other GNU Coreutils tools, check that you have “info” installed and call:
$ info '(coreutils.info.gz)Relative items in date strings'
Oh, and this whole story about setting modification dates manually to arbitrary values also means that the “Tattletale Statistics: Blogtimes November 2010” image in my blog’s side bar is absolute nonsense, at least this month. Well, never trust any statistic you haven’t faked yourself. ;-)
But on the other hand, the dates in the example may give a hint when I really wrote that blog posting. Or not. ;-)
And I wonder what my backup tools think about last modification times
in the future. Well, they probably only check for modification dates
newer than last backup and therefore should be fine. *phew*
Tagged as: Blogging, Blosxom, date, dates, GNU Coreutils, Myon, Statistics, touch, UUUCO, UUUT
2 comments // show without comments // write a comment