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命令詳解用法

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