温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

linux中hash命令的用法

发布时间:2020-06-02 11:23:09 来源:亿速云 阅读:709 作者:Leah 栏目:系统运维

相信新手对linux中hash命令的用法处于一知半解状态,小编给大家总结了以下内容。如下资料是关于hash命令的内容。

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

看完上述内容,你们对linux中hash命令的用法有进一步的了解吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI