touch Command Purpose Updates the access and modification times of a file. Syntax touch [ -a ] [ -c ] [ -m ] [ -f ] [ -r RefFile ] [ Time | -t Time ] { File ... | Directory ... } Description 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 com- mand creates the file unless you specify the -c flag. The locale command information variables D_FMT and T_FMT specify the order of month and day in the date specification and the ord- er of hour and minute in the time specification. If undefined, these orders default to a MMDDhhmm format. 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). Flags -a Changes the access time of the file specified by the File var- iable. Does not change the modification time unless -m is also specified. -c Does not create the file if it does not already exist. No di- agnostic messages are written concerning this condition. -f Attempts to force the touch in spite of read and write permis- sions on a file. -m Changes the modification time of File. Does not change the access time unless -a is also specified. -r RefFile Uses the corresponding time of the file specified by the RefFile variable instead of the current time. Time Specifies the date and time of the new timestamp in the for- mat MMDDhhmm[yy], where: MM Specifies the month of the year (01 to 12). DD Specifies the day of the month (01 to 31). hh Specifies the hour of the day (00 to 23). mm Specifies the minute of the hour (00 to 59). yy Specifies the last two digits of the year. If the yy variable is not specified, the default value is the current year. -t Time Uses the specified time instead of the current time. The Time variable is specified in the decimal form [[CC ]YY]MMDDhhmm[ .SS] where: CC Specifies the first two digits of the year. YY Specifies the last two digits of the year. MM Specifies the month of the year (01 to 12). DD Specifies the day of the month (01 to 31). hh Specifies the hour of the day (00 to 23). mm Specifies the minute of the hour (00 to 59). SS Specifies the second of the minute (00 to 59). Note: Do not specify the full path name /usr/bin/touch if you re- ceive an error message when using the touch command. Exit Status This command returns the following exit values: 0 The command executed successfully. All requested changes were made. >0 An error occurred. Examples 1. To update the access and modification times of a file, enter: touch program.c This 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. 2. To avoid creating a new file, enter: touch -c program.c 3. To update only the modification time, enter: touch -m *.o This updates the last modification times (not the access times) of the files that end with a .o extension in the current directo- ry. The touch command is often used in this way to alter the results of the make command. 4. To explicitly set the access and modification times, enter: touch -c -t 02171425 program.c This sets the access and modification dates to 14:25 (2:25 p.m.) February 17 of the current year. 5. To use the time stamp of another file instead of the current time, enter: touch -r file1 program.c This gives the program.c file the same time stamp as the file1 file. 6. To touch a file using a specified time other than the current time, enter: touch -t 198503030303.55 program.c This gives the program.c file a time stamp of 3:03:55 a.m. on March 3, 1985. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/touch Contains the touch command. Related Information The date command, locale command. The utime subroutine. Directory Overview in AIX Version 3.2 System User's Guide: Base and Devices describes the structure and characteristics of direc- tories in the file system. Files Overview in AIX Version 3.2 System User's Guide: Base and Devices describes files, file types, and how to name files. Understanding File and Directory Access Modes in AIX Version 3.2 System Management Guide: Operating System and Devices introduces file ownership and permissions to access files and directories. Understanding File Types in AIX Version 3.2 General Programming Concepts introduces the commands that control files.