touch

Official Description

Updates file access and modification times.

Syntax

touch [-acfm] [-r reference_file | -t time] file...
				

Options

-a changes only the access time.

-m changes only the modification time.

-r reference_file causes the specified file's times to be used instead of the current time.

-t time specifies the time to use.

Oddities

It can be used to create an empty file.

Example

$ ls -l d*                   # Note date
-rw-rw-r--   1 obrien   obrien         22 Nov 27 00:32 do_funcy
$
$ date                       # Current date
Mon Nov 27 15:32:30 EST 2000
$
$ touch do_funcy             # Alter date on file
$
$ ls -l d*                   # Note date change
-rw-rw-r--   1 obrien   obrien         22 Nov 27 15:32 do_funcy
$
$ touch denfile              # Create empty file
$
$ ls -l d*                   # Note size
-rw-rw-r--   1 obrien   users           0 Nov 27 15:33 ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.