type 命令详解

 type 

作用:
用来显示指定命令的类型,判断出命令是内部命令还是外部命令。
命令类型:
alias: 别名
keyword:关键字, shell 保留字
function:函数, shell函数
builtin: 内置命令,shell内建命令
file: 文件,磁盘文件,外部命令
unfound: 没有找到
语法:
type (选项)(参数)
选项:
-t: 输出file/alias/builtin ,分别表示给定命令为外部命令,命令别名,内部命令
-p:如果给出的指令为外部命令,则显示绝对路径
-a:在环境变量PATH指定的路径中,显示给定指令信息,包括命令别名。
实例:
type ls : ls is aliased to 'ls --color = tty'
type cd : cd is a shell builtin
type date : date is /bin/date
type mysql: mysql is /usr/bin/mysql
type nginx:  -bash :type:nginx:notfound
type if :if is a shell keyword
type which : which is aliased to 'alias | /usr/bin/which --tty -only --read-alias --show -dot --show-title'
type -a cd : cd is a shell builtin
type -t cd : builtin
type -a grep: grep is /bin/grep

 

posted on 2015-03-27 17:27  linuxSu  阅读(1355)  评论(0编辑  收藏  举报

导航