touch -cr a.txt b.txtĬhange the access and modification times of b.txt to match the times of a.txt. If it's a symbolic link, change the times of the symlink, not the times of the referenced file. touch -h mysymĬhange the times of file mysym. If file.txt does not exist, it is created. The ctime is set to the current system time. touch -a file.txtĬhange the atime of file.txt. If file.txt exists, set its times to the current system time. If file.txt doesn't exist, create an empty file with that name. If file.txt exists, set its access, modification, and change times (atime, mtime, and ctime) to the current system time. The exit status of touch is zero if all operations were successful. To set the TZ environment variable, use the command tzselect. Otherwise, the system default time zone is used. If the value of environment variable TZ is set, all operations use that time zone. When a file is touched, the ctime is always set to the current system time. In addition to having write access, the user must also own a file to set its times to the past or future.īecause there is no way to manually set ctimes, the -r, -d, and -t options can modify only atimes and mtimes. If seconds are specified, they are to be preceded with a period (. Century, years, and seconds are optional, and may be specified as CCYYMMDDHHMM.SS. For example, 07040000 would be midnight on the fourth of July. t takes a numeric timestamp, which expresses the month, date, hour, and minute as MMDDHHMM. If seconds are specified, they are to be preceded in the time by a colon ( : ). Single digit numbers may be prefixed with a zero, or not, according to preference. The day may be specified before or after the month in the string. If the time is omitted, midnight is used. If year, month, or day are omitted, the current system time values are used. The -d option takes a human-readable date string. For example, -time=atime -time=mtime is the same as -am. This option can be specified twice nondestructively. The value of timetype must be one of the following: The format of timestamp is YY] MMDDhhmm.Īn alternate way to specify what type of time to set (as with -a and -m). Use the numeric timestamp instead of the current time. Set the times of file to the times of file reffile instead of the current time. This option implies -c: nothing is created if file does not exist. If this option is not specified, touch will dereference symlinks before making modifications. If file is a symbolic link and this option is specified, touch modifies the timestamp of the symlink, rather than its referenced file. This option does nothing, but is accepted to provide compatibility with BSD versions of touch. In addition to having write access, the user must also own a file to set its times to the past or future. Strings valid to the date command are accepted by the -d option. Parse the date string datestring, and use it instead of current time. With no options, touch changes the atime, mtime, and ctime of file to the current system time. (If file is a dash " -", touch modifies the special file descriptor standard output. Multiple files may be specified as file0 file1 file2. If file does not exist, it is created, unless the -c or -h options are used. The only required argument to touch is a file name: fileĪ file whose times should be changed. There is no way to manually set the ctime.Ī file's atime or mtime can be set to the future or the past if the user owns the file. Therefore, when you change the atime ( -a) or mtime ( -m) of a file, its ctime is automatically set to the current time. The atime and mtime are part of a file's status metadata. Status information includes a file's permissions and its timestamps.Įvery time anything happens to a file, at least one element of its status changes, and its ctime is set to the current system time. The last time the file's metadata, called the Status, was changed. The last time the file's contents were modified. In Linux, there are three timestamps associated with a file: Timestamp type For Unix like operating systems, the epoch is 00:00:00 UTC (Coordinated Universal Time), Thursday, 1 January 1970. Internally, the operating system stores these times as time elapsed since an arbitrary date called the epoch. A file can have multiple timestamps, and some of them can be "forged" by setting them manually. A timestamp is information associated with a file that identifies an important time in the file's history.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |