for each name,the full file name of command is determined by searching the directories in $PATH and remembered.
对于每个hash命令中的参数name,命令的完整文件名被从$PATH中搜寻到的目录的决定,而后hash命令记住这一结果。
hash [-p filename]
If the -p option is supplied,no path search is performed,and filename is used as the full file name of the command.
若是提供了-p选项,不执行路径搜索,将命令全路径path起别名为nameshell
the -r option causes the shell to forget allrembered locations -r选项发使shell忘记全部已经记住的位置 the -d option cause the shell to forget location of each name -d选项使shell忘记每个指定name的文件位置 If the -t option is supplied,the full pathnameto which each name corresponds is printed. 使用-t选项,每个匹配到的name的完整路径将会被输出。 If multiple name arguments are supplied with -t ,the name is printed before the hashed full pathname. 若是使用-t选项后不少个name的参数,输出以前会在hashed完整的路径名以前,加上name,一块儿输出。 The -l option cause output to be display in a format that may be reused as input. -l选项输出时按照一个格式显示,输出内容可能还能够做为输入使用。 If no arguments are given,or if only -l is supplied, information about rembered commands is printed. 若是没有参数,或者只跟一个-l选项,被记住的命令的信息会被输出 The return status is ture unless a name is not found or an invalid option is supplied 返回状态是ture,除非name没有找到,或者是一个无效的选项
当执行外部命令时,默认会从PATH路径下寻找该命令,找到后会将这条命令的路径记录到hash表缓存中,当再次使用该命令时,shell会首先查找hash表,若是存在的话,就执行,若是不存在将会去PATH中执行搜索。
命令格式
hash [-lr] [-p filename] [-dt] [name]
hash -p filename name: 将filename全路径起别名为name记录到hash中
hash -d name 清空指定name的缓存
hash -r 清空全部hash缓存
hash -t name 将全部匹配到的name所有输出
hash -t name1 name2 参数name若是是多个的话,会在对应的行开头显示名称。
hash -l [name] 按照一个特定格式显示hash缓存,还能够做为输入使用
hash后面没有参数 或者只有一个-l选项,hash表中的全部缓存信息将会被输出。不一样之处在于显示结果的格式不一样而已。缓存