Monday, October 16, 2006

The Power of Touch

This blog moved to a new location, please visit us at http://ramble.m2m.at.

If you are using Linux or some kind of Unix you properly have noticed the command touch.
touch [-acm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file [...]
Mostly it is used to create empty files, e.g. to create an empty file called new.txt:
touch new.txt
But it can much more. Originally it was build to manipulate the modification and access times of files. E.g. if you want to trick make to recompile a project just touch a file:
touch project.c
Sometimes if you work with NFS drives of servers with asynchronous time stamps, some applications do not recognize updated files and will work with a cached version for some time. Then you can use touch as dirty work around, e.g.:
touch -m 209901018000 cachedfile.txt
Or give a whole folder identical timestamps.

Have a look at the man page for more information.

No comments: