Touch (command)

File creation and timestamp updating shell command

touch

Example of `touch` usage

Original author(s)| AT&T Bell Laboratories
Developer(s)| Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, Randy Smith, TSC, Microware, Apple, Digital Research, Novell, Kris Heidenstrom
Initial release| January 1979; 46 years ago (1979-01)
Written in| 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
Type| Command
License| coreutils: GPLv3+
FreeDOS: GPLv2
ReactOS: BSD-4-Clause
BusyBox: GPL-2.0-only
Toybox: 0BSD
Plan 9: MIT License

`touch` is a shell command that sets the modification timestamp of an existing file to be current – 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 `touch` 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[1] and Touch for Windows.[2]), classic Mac OS, DOS, FreeDOS,[3][4] DR DOS 6.0,[5] KolibriOS,[6] FLEX,[7] AROS,[8] OS-9,[9] ReactOS,[10] and IBM i.[11] The version bundled in GNU Core Utilities was written by Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, and Randy Smith.[12]

## See also

[edit]

* System time
* List of POSIX commands

## References

[edit]

1. ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.
2. ^ "touch for Windows".
3. ^ "ibiblio.org FreeDOS Package -- touch (Unix-like)". www.ibiblio.org.
4. ^ "ibiblio.org FreeDOS Group -- Utilities". www.ibiblio.org.
5. ^ DR DOS 6.0 User Guide Optimisation and Configuration Tips
6. ^ "Shell - KolibriOS wiki". wiki.kolibrios.org.
7. ^ "FLEX 9.0 User's Manual" (PDF).
8. ^ "AROS Research Operating System". aros.sourceforge.io.
9. ^ Paul S. Dayan (1992). The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
10. ^ "reactos/reactos". GitHub.
11. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 5 September 2020.
12. ^ "touch(1): change file timestamps - Linux man page". linux.die.net.

## Further reading

[edit]

* McElhearn, Kirk (2006). The Mac OS X Command Line: Unix Under the Hood. John Wiley & Sons. ISBN 978-0470113851.

## External links

[edit]

The Wikibook Guide to Unix has a page on the topic of: Commands

* `touch` – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group
* `touch(1)` – Linux User Commands Manual
* `touch(1)` – Plan 9 Programmer's Manual, Volume 1
* `touch(1)` – Inferno General commands Manual
* examples showing how to use touch

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chattr
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* read
* sed
* sort
* strings
* tail
* tr
* troff
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

* v
* t
* e

Plan 9 command-line interface programs and shell builtins

File system|

* chmod
* chgrp
* cmp
* cp
* dd
* du
* file
* gzip
* ls
* mkdir
* pwd
* rm
* split
* tee
* touch

Processes|

* kill
* ps

User environment|

* passwd
* who

Text processing|

* awk
* basename
* comm
* diff
* ed
* eqn
* join
* sed
* sort
* spell
* strings
* tail
* tr
* troff
* uniq
* wc

Shell builtins|

* echo
* test

Networking|

* ip/ipconfig
* ip/ping
* netstat

Searching|

* grep

Software development|

* ar
* hoc
* lex
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* fortune
* sleep

*  Category

* v
* t
* e

GNU Core Utilities command-line interface programs

File system|

* chcon
* chmod
* chown
* chgrp
* cksum
* cp
* dd
* df
* dir
* dircolors
* install
* ln
* ls
* mkdir
* mkfifo
* mknod
* mktemp
* mv
* realpath
* rm
* rmdir
* shred
* sync
* touch
* truncate
* vdir

Text utilities|

* b2sum
* base32
* base64
* cat
* cksum
* comm
* csplit
* cut
* expand
* fmt
* fold
* head
* join
* md5sum
* nl
* numfmt
* od
* paste
* ptx
* pr
* sha1sum
* shuf
* sort
* split
* sum
* tac
* tail
* tr
* tsort
* unexpand
* uniq
* wc

Shell utilities|

* arch
* basename
* chroot
* date
* dirname
* du
* echo
* env
* expr
* factor
* false
* groups
* hostid
* id
* link
* logname
* nice
* nohup
* nproc
* pathchk
* pinky
* printenv
* printf
* pwd
* readlink
* runcon
* seq
* sleep
* stat
* stdbuf
* stty
* tee
* test
* timeout
* true
* tty
* uname
* unlink
* uptime
* users
* who
* whoami
* yes

*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template