Linux

  1. Home
  2. Computing & Technology
  3. Linux
Linux / Unix Command: touch
Command Library

NAME

touch

SYNOPSIS

touch [-acfm] [-r reference-file] [-t MMD-Dhhmm[[CC]YY][.ss]] [-d time]
[--time={atime,access,use,mtime,modify}] [--date=time]
[--file=reference-file] [--no-create] [--help] [--version]
file...

DESCRIPTION

Changes the date/time stamp of the file filename to the current time. Creates an empty file if the file does not exist. You can change the stamp to any date using

touch -t 200201311759.30 (year 2002 January day 31 time 17:59:30).

There are three date/time values associated with every file on an ext2 filesystem:

- the time of last access to the file (atime)
- the time of last modification to the file (mtime)
- the time of last change to the file's inode (ctime).

Touch will change the first two to the value specified, and the last one always to the current system time.

OPTIONS

-a, --time=atime, --time=access, --time=use
Change the access time only.

-c, --no-create
Do not create files that do not exist.

-d, --date time
Use time (which can be in various common formats)
instead of the current time. It can contain month
names, timezones, `am' and `pm', etc.

-m, --time=mtime, --time=modify
Change the modification time only.

-r, --file reference-file
Use the times of reference-file instead of the cur-
rent time.

-t MMDDhhmm[[CC]YY][.ss]
Use the argument (months, days, hours, minutes,
optional century and years, optional seconds)
instead of the current time.

--help Print a usage message on standard output and exit
successfully.

--version
Print version information on standard output then
exit successfully.

EXAMPLE

% touch analysis_data.xls

Changes the timestamp of file analysis_data.xls to the current time.

Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux Command Library Index

>> Also see Shell Command Library

Explore Linux

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Linux

  1. Home
  2. Computing & Technology
  3. Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.