hash:执行过的外部命令hash(缓存)表(因为是储存在内存中,所以退出后就会没有)
hash:显示hash缓存(不会显示命令名称或者定义的别名)
-p path name:将命令路径进行别名
-l:显示所有hash缓存(以-p形式显示)
-t:显示指定的name的路径
-d:删除指定的name
-r:清除所有的缓存表
[root@lqynkdcwy ~]# hash
hits command
3 /sbin/ifconfig
1 /bin/cat
2 /bin/pwd
1 /bin/ls
hash -p path name:将path1路径别名为name
[root@lqynkdcwy ~]# hash -p /bin/nano NANO
[root@lqynkdcwy ~]# hash -l
builtin hash -p /bin/nano NANO
builtin hash -p /sbin/ifconfig ifconfig
builtin hash -p /bin/cat cat
builtin hash -p /bin/pwd PWD
builtin hash -p /bin/ls ls
hash -l:以-p形式显示hash缓存表(默认与别名)
[root@lqynkdcwy ~]# hash -l
builtin hash -p /bin/nano NANO
builtin hash -p /sbin/ifconfig ifconfig
builtin hash -p /bin/cat cat
builtin hash -p /bin/pwd PWD
builtin hash -p /usr/bin/whereis whereis
builtin hash -p /bin/ls ls
hash -t name:(name为hash表中的名字----默认与别名)
[root@lqynkdcwy ~]# hash -t NANO
/bin/nano
[root@lqynkdcwy ~]# hash -t pwd (必须在hash表存在,没有就会报错)
-bash: hash: pwd: not found
[root@lqynkdcwy ~]# hash -t PWD
/bin/pwd
hash -d name:删除指定的name
[root@lqynkdcwy ~]# hash -l
builtin hash -p /bin/nano NANO
builtin hash -p /sbin/ifconfig ifconfig
builtin hash -p /bin/cat cat
builtin hash -p /bin/pwd PWD
builtin hash -p /usr/bin/whereis whereis
builtin hash -p /bin/ls ls
[root@lqynkdcwy ~]# hash -d NANO
[root@lqynkdcwy ~]# hash -l(已经没有了hash -d NANO)
builtin hash -p /sbin/ifconfig ifconfig
builtin hash -p /bin/cat cat
builtin hash -p /bin/pwd PWD
builtin hash -p /usr/bin/whereis whereis
builtin hash -p /bin/ls ls
hash -r:清除所有缓存
[root@lqynkdcwy ~]# hash
hits command
3 /sbin/ifconfig
1 /bin/cat
3 /bin/pwd
1 /usr/bin/whereis
1 /usr/bin/man
1 /bin/ls
[root@lqynkdcwy ~]# hash |wc -l
7
[root@lqynkdcwy ~]# hash -r
[root@lqynkdcwy ~]# hash |wc -l
1(为hits command这一行)