{{Short description|File creation and timestamp updating shell command}} {{lowercase}} {{Infobox software | name = touch | logo = | screenshot = Touch-example.png | screenshot size = | caption = Example of <code>touch</code> usage | author = AT&T Bell Laboratories | developer = Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, Randy Smith, TSC, Microware, Apple, Digital Research, Novell, Kris Heidenstrom | released = {{Start date and age|1979|1}} | latest release version = | latest release date = | programming language = C | operating system = Unix, Unix-like, Plan 9, Inferno, FLEX, OS-9, Classic Mac OS, Windows, DR DOS, AROS, FreeDOS, ReactOS, KolibriOS, IBM i | platform = Cross-platform | genre = Command | license = coreutils: GPLv3+<br />FreeDOS: GPLv2<br />ReactOS: BSD-4-Clause<br />BusyBox: GPL-2.0-only<br />Toybox: 0BSD<br />Plan 9: MIT License | website = }} '''<code>touch</code>''' is a shell command that sets the modification timestamp of an existing file to be current {{endash}} which on a Unix-based file system includes special files such as directories. If the input path does not specify an existing file, then it creates a new, regular file at the path.

The Single UNIX Specification (SUS) specifies that <code>touch</code> changes the access or modification timestamps, or both. The file is identified by file system path supplied as the sole argument. If the path does not specify a file, the command creates a file with access and modification timestamps as specified or by default to the current time.

By default (no options specified), touching a file is equivalent to creating it with no content or if it exists, opening and saving it without any content changes to update the modification timestamp to be current. This convenience functionality is useful for a variety of scenarios including build and backup. The tools used in such scenarios typically ignore files that are older than a certain point of time. For example, make ignores a source code file that is older than the object file it is used to create.

The command is often used to create a new file, so that can subsequently open it in an editor or to create a file required by an operation that does not require specific content.

A command first appeared in Version 7 AT&T UNIX. Today, the command is available for many operating systems, including many Unix and Unix-like systems, Windows (via UnxUtils<ref>{{Cite web|url=https://unxutils.sourceforge.net/|title=Native Win32 ports of some GNU utilities|website=unxutils.sourceforge.net|access-date=11 August 2025|archive-date=9 February 2006|archive-url=https://web.archive.org/web/20060209022842/http://unxutils.sourceforge.net/|url-status=live}}</ref> and Touch for Windows.<ref>{{Cite web|url=https://sourceforge.net/projects/touchforwindows/|title=touch for Windows}}</ref>), classic Mac OS, DOS, FreeDOS,<ref>{{Cite web|url=http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/touch.html|title=ibiblio.org FreeDOS Package -- touch (Unix-like)|website=www.ibiblio.org|access-date=13 November 2018|archive-date=13 March 2019|archive-url=https://web.archive.org/web/20190313222905/http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/touch.html|url-status=live}}</ref><ref>{{Cite web|url=http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-util.html|title=ibiblio.org FreeDOS Group -- Utilities|website=www.ibiblio.org|access-date=13 November 2018|archive-date=30 September 2018|archive-url=https://web.archive.org/web/20180930110109/http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/group-util.html|url-status=live}}</ref> DR DOS 6.0,<ref name="drdos6userguide">{{Cite web |url=https://www.4corn.co.uk/archive/docs/DR%20DOS%206.0%20User%20Guide-opt.pdf |title=DR DOS 6.0 User Guide Optimisation and Configuration Tips |access-date=11 August 2019 |archive-date=30 September 2019 |archive-url=https://web.archive.org/web/20190930135943/http://www.4corn.co.uk/archive/ |url-status=live }}</ref> KolibriOS,<ref>{{Cite web|url=http://wiki.kolibrios.org/wiki/Shell|title=Shell - KolibriOS wiki|website=wiki.kolibrios.org|access-date=11 August 2019|archive-date=11 February 2019|archive-url=https://web.archive.org/web/20190211231827/http://wiki.kolibrios.org/wiki/Shell|url-status=live}}</ref> FLEX,<ref>{{Cite web|url=http://www.flexusergroup.com/flexusergroup/pdfs/swflexum.pdf|title=FLEX 9.0 User's Manual|access-date=10 June 2019|archive-date=25 July 2021|archive-url=https://web.archive.org/web/20210725110201/http://www.flexusergroup.com/flexusergroup/pdfs/swflexum.pdf|url-status=live}}</ref> AROS,<ref>{{Cite web|url=https://aros.sourceforge.io/documentation/users/shell/index.php|title=AROS Research Operating System|website=aros.sourceforge.io|access-date=12 September 2020|archive-date=2 July 2019|archive-url=https://web.archive.org/web/20190702203042/http://aros.sourceforge.net/documentation/users/shell/index.php|url-status=dead}}</ref> OS-9,<ref>{{cite book|author=Paul S. Dayan|year=1992|title=The OS-9 Guru - 1 : The Facts|publisher=Galactic Industrial Limited|isbn=0-9519228-0-7}}</ref> ReactOS,<ref>{{Cite web|url=https://github.com/reactos/reactos|title=reactos/reactos|website=GitHub|access-date=29 July 2019|archive-date=11 December 2017|archive-url=https://web.archive.org/web/20171211170155/https://github.com/reactos/reactos|url-status=live}}</ref> and IBM i.<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=IBM |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 |archive-date=18 September 2020 |archive-url=https://web.archive.org/web/20200918130823/https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |url-status=live }}</ref> The version bundled in GNU Core Utilities was written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, and Randy Smith.<ref>{{Cite web|url=https://linux.die.net/man/1/touch|title=touch(1): change file timestamps - Linux man page|website=linux.die.net|access-date=27 January 2019|archive-date=27 March 2019|archive-url=https://web.archive.org/web/20190327025856/https://linux.die.net/man/1/touch|url-status=live}}</ref>

==See also== * System time * List of POSIX commands

==References== {{Reflist}}

==Further reading== *{{Cite book|author-last=McElhearn|author-first=Kirk|title=The Mac OS X Command Line: Unix Under the Hood|date=2006|publisher=John Wiley & Sons|isbn=978-0470113851}}

==External links== {{Wikibooks|Guide to Unix|Commands}} * {{man|cu|touch|SUS}} * {{man|1|touch|die.net}} * {{man|1|touch|Plan 9}} * {{man|1|touch|Inferno}} * [http://www.linfo.org/touch.html examples showing how to use touch]

{{Unix commands}} {{Plan 9 commands}} {{Core Utilities commands}} {{Use dmy dates|date=March 2014}}

Category:Standard Unix programs Category:Unix SUS2008 utilities Category:Plan 9 commands Category:Inferno (operating system) commands Category:ReactOS commands Category:IBM i Qshell commands