Updates the access and modification times of a file.
touch [ -a ] [ -c ] [ -m ] [ -f ] [ -r RefFile ] [ Time | -t Time ] { File ... | Directory ... }
The touch command updates the access and modification times of each file specified by the File parameter of each directory specified by the Directory parameter. If you do not specify a value for the Time variable, the touch command uses the current time. If you specify a file that does not exist, the touch command creates the file unless you specify the -c flag.
The return code from the touch command is the number of files for which the times could not be successfully modified (including files that did not exist and were not created).
Note: Any dates beyond and including the year 2038 are invalid.
Notes:
- The touch command calls the utime () subroutine to change the modification and access times of the file touched. This may cause the touch command to fail when flags are used if you do not actually own the file, even though you may have write permission to the file.
- Do not specify the full path name /usr/bin/touch if you receive an error message when using the touch command.
This command returns the following exit values:
0 | The command executed successfully. All requested changes were made. |
>0 | An error occurred. |
touch program.cThis sets the last access and modification times of the program.c file to the current date and time. If the program.c file does not exist, the touch command creates an empty file with that name.
touch -c program.c
touch -m *.oThis updates the last modification times (not the access times) of the files that end with a .o extension in the current directory. The touch command is often used in this way to alter the results of the make command.
touch -c -t 02171425 program.cThis sets the access and modification dates to 14:25 (2:25 p.m.) February 17 of the current year.
touch -r file1 program.cThis gives the program.c file the same time stamp as the file1 file.
touch -t 198503030303.55 program.cThis gives the program.c file a time stamp of 3:03:55 a.m. on March 3, 1985.
/usr/bin/touch | Contains the touch command. |
The date command, locale command.
The utime subroutine.
Directory Overview in AIX Version 4.3 System User's Guide: Operating System and Devices describes the structure and characteristics of directories in the file system.
Files Overview in AIX Version 4.3 System User's Guide: Operating System and Devices describes files, file types, and how to name files.
File and Directory Access Modes in AIX Version 4.3 System User's Guide: Operating System and Devices introduces file ownership and permissions to access files and directories.
Understanding File Types in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs introduces the commands that control files.