Jump to Navigation

044 - touch command

1. Create an empty file

$ touch myfile

2. touch command changes two timestamps associated with a file

$ touch -d "Dec 18 2007" myfile

$ stat myfile

File: `myfile'
Size: 0               Blocks: 0          IO Block: 65536  regular empty file
Device: 84d56294h/2228576916d   Inode: 2251799813855466  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/    isao)   Gid: (  513/    None)
Access: 2007-12-18 10:00:00.000000000 -0800
Modify: 2007-12-18 10:00:00.000000000 -0800
Change: 2008-12-19 10:04:05.940635800 -0800

3. Useful option

-a    Change the access time only.

-m   Change the modification only.

-c     If the file doesn't exist, don't create it (normally, touch creates it).

-d    timestamp(exp: "12/28/2001 3pm", "Dec 18 2007 10:00" ... )

-t     timestamp(exp: "20030812150047" ...)

Linux:


Main menu 2

Story | by Dr. Radut