touch your files

November 14th, 2006 toydi Posted in Common, stat, touch | Hits: 18190 | 2 Comments »

When you touch a file, you change both its accessed and modified time.

Here’s a file and its status:

$ stat foobar
File: `foobar'
Size: 154             Blocks: 8          IO Block: 4096   regular file
Device: 304h/772d       Inode: 167769      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   toydi)   Gid: ( 1000/   toydi)
Access: 2006-11-14 22:06:06.000000000 +0800
Modify: 2006-11-14 21:40:05.000000000 +0800
Change: 2006-11-14 21:40:05.000000000 +0800

Now, touch it!

touch foobar
$ stat foobar
File: `foobar'
Size: 154             Blocks: 8          IO Block: 4096   regular file
Device: 304h/772d       Inode: 167769      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   toydi)   Gid: ( 1000/   toydi)
Access: 2006-11-14 22:08:38.000000000 +0800
Modify: 2006-11-14 22:08:38.000000000 +0800
Change: 2006-11-14 22:08:38.000000000 +0800

When you touch a file which doesn’t exist, that file will be created. To prevent this, use the -c option.

2 Responses to “touch your files”

  1. When you touch nothing, nothing will be created, and nothing is a file that contains nothing.

  2. mysurface, read like a Zen poem. 8-)

Leave a Reply