'\" te .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Copyright 1989 AT&T .\" Portions Copyright (c) 2009, 2010, Oracle and/or its affiliates.All rights reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH touch 1 "2010 年 11 月 8 日" "SunOS 5.11" "用户命令" .SH 名称 touch, settime \- 更改文件访问时间和修改时间 .SH 用法概要 .LP .nf \fBtouch\fR [\fB-acm\fR] [\fB-r\fR \fIref_file\fR | \fB-t\fR \fItime\fR | \fB-d\fR \fIdate_time\fR] \fIfile\fR... .fi .LP .nf \fBtouch\fR [\fB-acm\fR] [\fItime_spec\fR] \fIfile\fR... .fi .LP .nf \fBsettime\fR [\fB-f\fR \fIref_file\fR] [\fItime_spec\fR] \fIfile\fR... .fi .SH 描述 .sp .LP \fBtouch\fR 实用程序可设置每个文件的访问时间和修改时间。如果 \fIfile\fR 操作数尚未存在,则会创建该操作数。 .sp .LP 使用的时间可由 \fB-t\fR \fItime\fR、\fB-d\fR \fIdate_time\fR、\fB-r\fR \fIref_file\fR 引用的文件的相应时间字段或 \fItime_spec\fR 操作数指定。如果这些均未指定,\fBtouch\fR 将使用当前时间。 .sp .LP 如果 \fB-a\fR 和 \fB-m\fR 选项均未指定,\fBtouch\fR 将更新修改时间和访问时间。 .sp .LP 如果用户对某个文件具有写入访问权限,但不是该文件的所有者或超级用户,则只能将该文件的修改时间和访问时间更改为当前时间。尝试使用 \fBtouch\fR 设置特定时间会导致错误。 .sp .LP \fBsettime\fR 实用程序等效于 \fBtouch\fR \fB-c\fR [\fItime_spec\fR] \fIfile\fR。 .SH 选项 .sp .LP \fBtouch\fR 和 \fBsettime\fR 实用程序支持以下选项: .SS "touch" .sp .LP \fBtouch\fR 实用程序支持以下选项: .sp .ne 2 .mk .na \fB\fB-a\fR\fR .ad .sp .6 .RS 4n 更改 \fIfile\fR 的访问时间。除非也指定了 \fB-m\fR,否则不会更改修改时间。 .RE .sp .ne 2 .mk .na \fB\fB-c\fR\fR .ad .sp .6 .RS 4n 如果指定的 \fIfile\fR 不存在,则不会创建它。不会写入关于这种情况的任何诊断消息。 .RE .sp .ne 2 .mk .na \fB\fB-d\fR \fIdate_time\fR\fR .ad .sp .6 .RS 4n 使用指定的 date_time 而非当前时间。选项参数必须是以下格式的字符串: .sp .in +2 .nf \fIYYYY\fR-\fIMM\fR-\fIDDThh\fR:\fImm\fR:\fISS\fR[.\fIfrac\fR][\fItz\fR] .fi .in -2 .sp 或 .sp .in +2 .nf \fIYYYY\fR-\fIMM\fR-\fIDDThh\fR:\fImm\fR:\fISS\fR[,\fIfrac\fR][\fItz\fR] .fi .in -2 .sp 其中 .RS +4 .TP .ie t \(bu .el o \fIYYYY\fR 是至少四个十进制数字,表示年份 .RE .RS +4 .TP .ie t \(bu .el o \fIMM\fR、\fIDD\fR、\fIhh\fR、\fImm\fR 和 \fISS\fR 与 \fB-t\fR \fItime\fR 一样 .RE .RS +4 .TP .ie t \(bu .el o \fIT\fR 是字母 \fBT\fR 或单个 SPACE 字符 .RE .RS +4 .TP .ie t \(bu .el o [\fI\&.frac\fR] 和 [\fI,frac\fR] 可以为空,也可以分别是句点 (\fB\&.\fR) 或逗号 (\fB,\fR),后跟一个或多个十进制数字,指定小数形式的秒 .RE .RS +4 .TP .ie t \(bu .el o [\fItz\fR] 可以为空,表示本地时间,也可以是字母 \fBZ\fR,表示 UTC。如果 [\fItz\fR] 为空,则得到的时间受 \fBTZ\fR 环境变量值的影响 .RE .RE .sp .ne 2 .mk .na \fB\fB-m\fR\fR .ad .sp .6 .RS 4n 更改 \fIfile\fR 的修改时间。除非也指定了 \fB-a\fR,否则不会更改访问时间。 .RE .sp .ne 2 .mk .na \fB\fB-r\fR \fIref_file\fR\fR .ad .sp .6 .RS 4n 使用 \fIref_file\fR 指定的文件的相应时间而非当前时间。 .RE .sp .ne 2 .mk .na \fB\fB-t\fR \fItime\fR\fR .ad .sp .6 .RS 4n 使用指定的 \fItime\fR 而非当前时间。\fItime\fR 是以下格式的十进制数字: .sp .in +2 .nf [[\fICC\fR]\fIYY\fR]\fIMMDDhhmm\fR[\fI\&.SS\fR] .fi .in -2 .sp 其中每个两位数字表示以下内容: .sp .ne 2 .mk .na \fB\fIMM\fR\fR .ad .sp .6 .RS 4n 年中某月 [01-12]。 .RE .sp .ne 2 .mk .na \fB\fIDD\fR\fR .ad .sp .6 .RS 4n 月中某日 [01-31]。 .RE .sp .ne 2 .mk .na \fB\fIhh\fR\fR .ad .sp .6 .RS 4n 日中某时 [00-23]。 .RE .sp .ne 2 .mk .na \fB\fImm\fR\fR .ad .sp .6 .RS 4n 时中某分 [00-59]。 .RE .sp .ne 2 .mk .na \fB\fICC\fR\fR .ad .sp .6 .RS 4n 年份的前两位数字。 .RE .sp .ne 2 .mk .na \fB\fIYY\fR\fR .ad .sp .6 .RS 4n 年份的后两位数字。 .RE .sp .ne 2 .mk .na \fB\fISS\fR\fR .ad .sp .6 .RS 4n 分中某秒 [00-61]。 .RE \fICC\fR 和 \fIYY\fR 均为可选内容。如果均未指定,则假定使用当前年份。如果指定了 \fIYY\fR 但未指定 \fICC\fR,将按如下方式推导 \fICC\fR: .sp .sp .TS tab() box; cw(2.75i) cw(2.75i) lw(2.75i) lw(2.75i) . YY 假定值CC 推导值 _ 69-9919 00-3820 39-68ERROR .TE 得到的时间受 \fBTZ\fR 环境变量值的影响。有效时间范围是自新纪元起到 2038 年 1 月 18 日。 .sp \fISS\fR 范围是 [00-61] 而非 [00-59],因为存在闰秒现象。如果 \fISS\fR 为 60 或 61,则得到的时间(受 \fBTZ\fR 环境变量的影响)并不是指闰秒,得到的时间是 \fISS\fR 为 59 后的一秒或两秒。如果未指定 \fISS\fR,则假定为 0。 .RE .SS "settime" .sp .LP \fBsettime\fR 实用程序支持以下选项: .sp .ne 2 .mk .na \fB\fB-f\fR \fIref_file\fR\fR .ad .sp .6 .RS 4n 使用 \fIref_file\fR 指定的文件的相应时间而非当前时间。 .RE .SH 操作数 .sp .LP \fBtouch\fR 和 \fBsettime\fR 实用程序支持以下操作数: .sp .ne 2 .mk .na \fB\fIfile\fR\fR .ad .sp .6 .RS 4n 要修改其时间的文件的路径名。 .RE .sp .ne 2 .mk .na \fB\fItime_spec\fR\fR .ad .sp .6 .RS 4n 使用指定的 \fItime_spec\fR 而非当前时间。该操作数是以下格式的十进制数字: .sp .in +2 .nf \fIMMDDhhmm\fR[\fIYY\fR] .fi .in -2 .sp 其中每个两位数字表示以下内容: .sp .ne 2 .mk .na \fB\fIMM\fR\fR .ad .sp .6 .RS 4n 年中某月 [01-12]。 .RE .sp .ne 2 .mk .na \fB\fIDD\fR\fR .ad .sp .6 .RS 4n 月中某日 [01-31]。 .RE .sp .ne 2 .mk .na \fB\fIhh\fR\fR .ad .sp .6 .RS 4n 日中某时 [00-23]。 .RE .sp .ne 2 .mk .na \fB\fImm\fR\fR .ad .sp .6 .RS 4n 时中某分 [00-59]。 .RE .sp .ne 2 .mk .na \fB\fIYY\fR\fR .ad .sp .6 .RS 4n 年份的后两位数字。 .sp \fIYY\fR 是可选内容。如果将其省略,则假定使用当前年份。如果指定了 \fIYY\fR,将按如下方式推导年份: .RE .sp .sp .TS tab() box; cw(2.75i) cw(2.75i) lw(2.75i) lw(2.75i) . YY对应年份 69-991969-1999 00-382000-2038 39-68ERROR .TE 如果未指定 \fB-d\fR、\fB-r\fR 或 \fB-t\fR 选项,指定了至少两个操作数而且第一个操作数是八位或十位十进制整数,则假定第一个操作数为 \fItime_spec\fR 操作数。否则,假定第一个操作数为 \fIfile\fR 操作数。 .RE .SH 用法 .sp .LP 有关 \fBtouch\fR 遇到大于或等于 2 GB(2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 环境变量 .sp .LP 有关影响 \fBtouch\fR 执行的环境变量 \fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLANG\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR 的说明,请参见 \fBenviron\fR(5)。 .sp .ne 2 .mk .na \fB\fBTZ\fR\fR .ad .sp .6 .RS 4n 确定用于解释 \fItime\fR 或 \fIdate_time\fR 选项参数或者 \fItime_spec\fR 操作数的时区。 .RE .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .sp .6 .RS 4n \fBtouch\fR 实用程序已成功执行,请求的所有更改都已完成。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .sp .6 .RS 4n 出现错误。\fBtouch\fR 实用程序返回了无法成功修改其时间的文件的数目。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ CSIEnabled(已启用) _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBfutimens\fR(2)、\fBstat\fR(2)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBlargefile\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP 熟悉 BSD 环境的用户发现,使用 \fBtouch\fR 实用程序时,将接受但会忽略 \fB-f\fR 选项。无需使用 \fB-f\fR 选项,因为无论用户对文件有何种权限,\fBtouch\fR 都能成功处理其拥有的所有文件。