hash命令详解用法

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起别名为name

     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命令详解用法
hash -d name 清空指定name的缓存
hash命令详解用法
hash -r 清空所有hash缓存
hash命令详解用法
hash -t name 将所有匹配到的name全部输出
hash命令详解用法
hash -t name1 name2 参数name如果是多个的话,会在对应的行开头显示名称。
hash命令详解用法
hash -l [name] 按照一个特定格式显示hash缓存,还可以作为输入使用
hash命令详解用法
hash后面没有参数 或者只有一个-l选项,hash表中的所有缓存信息将会被输出。不同之处在于显示结果的格式不同而已。
hash命令详解用法

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章