{
    "mode": "info",
    "parameter": "touch",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/touch/json",
    "generated": "2026-07-30T14:16:50Z",
    "sections": {
        "File: coreutils.info,  Node: touch invocation,  Prev: chmod invocation,  Up: Changing file attributes": {
            "content": "",
            "subsections": [
                {
                    "name": "13.4 'touch': Change file timestamps",
                    "content": "'touch' changes the access and/or modification timestamps of the\nspecified files.  Synopsis:\n\ntouch [OPTION]... FILE...\n\nAny FILE argument that does not exist is created empty, unless option\n'--no-create' ('-c') or '--no-dereference' ('-h') was in effect.\n\nA FILE argument string of '-' is handled specially and causes 'touch'\nto change the times of the file associated with standard output.\n\nBy default, 'touch' sets file timestamps to the current time."
                }
            ]
        },
        "Because 'touch' acts on its operands left to right, the resulting": {
            "content": "timestamps of earlier and later operands may disagree.\n\nWhen setting file timestamps to the current time, 'touch' can change\nthe timestamps for files that the user does not own but has write\npermission for.  Otherwise, the user must own the files.  Some older\nsystems have a further restriction: the user must own the files unless\nboth the access and modification timestamps are being set to the current\ntime.\n\nThe 'touch' command cannot set a file's status change timestamp to a\nuser-specified value, and cannot change the file's birth time (if\nsupported) at all.  Also, 'touch' has issues similar to those affecting\nall programs that update file timestamps.  For example, 'touch' may set\na file's timestamp to a value that differs slightly from the requested\ntime.  *Note File timestamps::.\n\nTimestamps assume the time zone rules specified by the 'TZ'\nenvironment variable, or by the system default rules if 'TZ' is not set.\n*Note Specifying the Time Zone with 'TZ': (libc)TZ Variable.  You can\navoid ambiguities during daylight saving transitions by using UTC\ntimestamps.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-a'\n'--time=atime'\n'--time=access'\n'--time=use'\nChange the access timestamp only.  *Note File timestamps::.\n\n'-c'\n'--no-create'\nDo not warn about or create files that do not exist.\n\n'-d TIME'\n'--date=TIME'\nUse TIME instead of the current time.  It can contain month names,\ntime zones, 'am' and 'pm', 'yesterday', etc.  For example,\n'--date=\"2004-02-27 14:19:13.489392193 +0530\"' specifies the\ninstant of time that is 489,392,193 nanoseconds after February 27,\n2004 at 2:19:13 PM in a time zone that is 5 hours and 30 minutes\neast of UTC.  *Note Date input formats::.  File systems that do not\nsupport high-resolution timestamps silently ignore any excess\nprecision here.\n\n'-f'\nIgnored; for compatibility with BSD versions of 'touch'.\n\n'-h'\n'--no-dereference'\nAttempt to change the timestamps of a symbolic link, rather than\nwhat the link refers to.  When using this option, empty files are\nnot created, but option '-c' must also be used to avoid warning\nabout files that do not exist.  Not all systems support changing\nthe timestamps of symlinks, since underlying system support for\nthis action was not required until POSIX 2008.  Also, on some\nsystems, the mere act of examining a symbolic link changes the\naccess timestamp, such that only changes to the modification\ntimestamp will persist long enough to be observable.  When coupled\nwith option '-r', a reference timestamp is taken from a symbolic\nlink rather than the file it refers to.\n\n'-m'\n'--time=mtime'\n'--time=modify'\nChange the modification timestamp only.\n\n'-r FILE'\n'--reference=FILE'\nUse the times of the reference FILE instead of the current time.\nIf this option is combined with the '--date=TIME' ('-d TIME')\noption, the reference FILE's time is the origin for any relative\nTIMEs given, but is otherwise ignored.  For example, '-r foo -d '-5\nseconds'' specifies a timestamp equal to five seconds before the\ncorresponding timestamp for 'foo'.  If FILE is a symbolic link, the\nreference timestamp is taken from the target of the symlink, unless\n'-h' was also in effect.\n\n'-t [[CC]YY]MMDDHHMM[.SS]'\nUse the argument (optional four-digit or two-digit years, months,\ndays, hours, minutes, optional seconds) instead of the current\ntime.  If the year is specified with only two digits, then CC is 20\nfor years in the range 0 ... 68, and 19 for years in 69 ... 99.  If\nno digits of the year are specified, the argument is interpreted as\na date in the current year.  On the atypical systems that support\nleap seconds, SS may be '60'.\n\nOn systems predating POSIX 1003.1-2001, 'touch' supports an obsolete\nsyntax, as follows.  If no timestamp is given with any of the '-d',\n'-r', or '-t' options, and if there are two or more FILEs and the first\nFILE is of the form 'MMDDHHMM[YY]' and this would be a valid argument to\nthe '-t' option (if the YY, if any, were moved to the front), and if the\nrepresented year is in the range 1969-1999, that argument is interpreted\nas the time for the other files instead of as a file name.  Although\nthis obsolete behavior can be controlled with the 'POSIX2VERSION'\nenvironment variable (*note Standards conformance::), portable scripts\nshould avoid commands whose behavior depends on this variable.  For\nexample, use 'touch ./12312359 main.c' or 'touch -t 12312359 main.c'\nrather than the ambiguous 'touch 12312359 main.c'.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}