'\" te .\" Copyright (c) 2002, 2011, Oracle and/or its affiliates.All rights reserved. .\" Copyright 1989 AT&T .\" Copyright (c) 1992, X/Open Company Limited 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 hash 1 "2011 年 7 月 12 日" "SunOS 5.11" "用户命令" .SH 名称 hash, rehash, unhash, hashstat \- 计算目录内容的内部散列表 .SH 用法概要 .LP .nf \fB/usr/bin/hash\fR [\fIutility\fR] .fi .LP .nf \fB/usr/bin/hash\fR [\fB-r\fR] .fi .SS "sh" .LP .nf \fBhash\fR [\fB-r\fR] [\fIname\fR]... .fi .SS "csh" .LP .nf \fBrehash\fR .fi .LP .nf \fBunhash\fR .fi .LP .nf \fBhashstat\fR .fi .SS "ksh88" .LP .nf \fBhash\fR [\fIname\fR]... .fi .LP .nf \fBhash\fR [\fB-r\fR] .fi .SH 描述 .SS "/usr/bin/hash" .sp .LP \fB/usr/bin/hash\fR 实用程序影响当前 shell 环境记录所发现的实用程序的位置的方式。它根据指定的参数将实用程序位置添加至它记录的位置列表,或者清除该列表的内容。未指定参数时,它将报告列表的内容。使用 \fB-r\fR 选项时,shell 会清除它记录的所有位置。 .sp .LP \fBhash\fR 不会报告作为 shell 内置命令提供的实用程序。 .SS "sh" .sp .LP 对于每个 \fIname\fR,shell 都会确定并记录 \fIname\fR 指定的命令搜索路径中的位置。使用 \fBhash\fR 内置命令的 \fB-r\fR 选项时,shell 会清除所记录的所有位置。未指定任何参数时,\fBhash\fR 将提供有关已记录的命令的信息。输出中的 \fIHits\fR 列是 shell 进程调用某个命令的次数。输出中的 \fICost\fR 列是找到搜索路径中的命令所需的工作量的度量。如果在搜索路径中的某个“相对”目录中找到一个命令,则更改到该目录后,该命令的存储位置将重新计算。需要对其执行此重新计算的命令由 \fIHits\fR 信息旁的一个星号 (\fB*\fR) 予以指示。在执行重新计算后,\fICost\fR 将递增。 .SS "csh" .sp .LP \fBrehash\fR 重新计算 \fBpath\fR 环境变量中列出的目录内容的内部散列表,以便计入新添加的命令。 .sp .LP \fBunhash\fR 禁用内部散列表。 .sp .LP \fBhashstat\fR 输出一个统计信息行以指明内部散列表在定位命令(和避免执行 \fBexec\fR)时的有效程度。对于散列函数指示可能存在命中项的 \fIpath\fR 的每个组件,以及在未以 " / " 开头的每个组件中,都将尝试执行 \fBexec\fR。 .SS "ksh88" .sp .LP 对于每个 \fIname\fR,shell 都会确定并记录 \fIname\fR 指定的命令搜索路径中的位置。使用 \fBhash\fR 内置命令的 \fB-r\fR 选项时,shell 会清除所记录的所有位置。未指定任何参数时,\fBhash\fR 将提供有关已记录的命令的信息。 .SH 操作数 .sp .LP \fBhash\fR 支持以下操作数: .sp .ne 2 .mk .na \fB\fIutility\fR\fR .ad .RS 11n .rt 要搜索和添加到所记录的位置列表的实用程序的名称。 .RE .SH 输出 .sp .LP 未指定参数时,将使用 \fBhash\fR 的标准输出。标准输出的格式不指定,但将包含当前 shell 环境中记录的位置列表中每个实用程序的路径名。此列表由以前调用的 \fBhash\fR 调用中指定的那些实用程序构成,还可能包含通过普通命令搜索进程调用和找到的那些实用程序。 .SH 环境变量 .sp .LP 有关影响 \fBhash\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .sp .ne 2 .mk .na \fB\fBPATH\fR\fR .ad .RS 8n .rt 确定 \fIutility\fR 的位置。 .RE .SH 退出状态 .sp .LP \fBhash\fR 返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 成功完成。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。 .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 _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBcsh\fR(1)、\fBksh88\fR(1)、\fBsh\fR(1)、\fBattributes\fR(5)、\fBenviron\fR(5)、\fBstandards\fR(5)