It seems there is more programs can do “next monday” than I have previously thought. I was reading touch‘s help message, and realized that it could also accept date string to use as touched time:


$ touch thefile
$ touch -m -d 'next monday' thefile
$ stat thefile
File: ‘thefile’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 803h/2051d Inode: 4120598 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/livibetter) Gid: ( 1000/livibetter)
Access: 2013-10-28 11:02:58.000000000 +0800
Modify: 2013-11-04 00:00:00.000000000 +0800
Change: 2013-10-28 11:03:11.000000000 +0800
Birth: -

touch and date both use the same parse_datetime function to parse the date string, only two from coreutils.

After learning this feature, I can not say I know 100% of what touch can do. Years ago, I would only think touch is for creating a file. But way far from it, and that’s not why it’s made. Look at -c option, -h and the reference file -r option, it’s more than that and not limited to files, but also directories.

With -a, -m, and -t to complete, yep, I know how to touch like how I know how to sleep 8h every day.