---
name: "touch"
section: "3"
platform: "macos"
package: "ksh"
version: "42"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/touch/3"
---

# touch(3)

set file access and modify times

## NAME

touch - set file access and modify times

## SYNOPSIS

$1$2#include \<ast.h\>#include \<ast.h\>#include \<ast.h\>#include \<ast.h\>#include \<ast.h\>#include \<ast.h\>#include \<ast.h\>#include \<ast.h\>

$1$2int touch(const char\* path, time\_t atime, time\_t mtime, int force);int touch(const char\* path, time\_t atime, time\_t mtime, int force);int touch(const char\* path, time\_t atime, time\_t mtime, int force);int touch(const char\* path, time\_t atime, time\_t mtime, int force);int touch(const char\* path, time\_t atime, time\_t mtime, int force);int touch(const char\* path, time\_t atime, time\_t mtime, int force);int touch(const char\* path, time\_t atime, time\_t mtime, int force);int touch(const char\* path, time\_t atime, time\_t mtime, int force);

## DESCRIPTION

$1$2touchtouchtouchtouchtouchtouchtouchtouch sets the access and modify times of the file named by $1$2pathpathpathpathpathpathpathpath If $1$2force != 0force != 0force != 0force != 0force != 0force != 0force != 0force != 0 then the file is created if it doesn't exist; otherwise the file is not created and $1$2-1-1-1-1-1-1-1-1 is returned. If $1$2force \< 0force \< 0force \< 0force \< 0force \< 0force \< 0force \< 0force \< 0 then $1$2atimeatimeatimeatimeatimeatimeatimeatime and $1$2mtimemtimemtimemtimemtimemtimemtimemtime are taken verbatim; otherwise $1$2(time\_t)(-1)(time\_t)(-1)(time\_t)(-1)(time\_t)(-1)(time\_t)(-1)(time\_t)(-1)(time\_t)(-1)(time\_t)(-1) retains the current value for the file and $1$2(time\_t)(0)(time\_t)(0)(time\_t)(0)(time\_t)(0)(time\_t)(0)(time\_t)(0)(time\_t)(0)(time\_t)(0) uses the current time.

## CAVEATS

By default the change time is always changed to the current time.
