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起別名爲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命令詳解用法
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命令詳解用法緩存

相關文章
相關標籤/搜索