#Bash 的 type 命令
type [-afptP] NAME...
功能
查看命令的类型。
类型
Bash 内置命令。
参数
-a- 查看所有同名的命令类型-f- 忽略函数-P- 强制从 PATH 中搜索,即使参数是内置命令、别名或函数等-p- 仅当命令是文件时打印其路径,其它类型不打印-t- 仅打印类型名:alias(别名)keyword(关键字)function(函数)builtin(内置命令)file(文件)(空)(命令不存在)
NAME- 要查询类型的命令列表
#示例
$ type ls
ls is aliased to `ls --color=auto'
$ type -a ls # 查看所有 ls
ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
ls is /bin/ls
$ type cd
cd is a shell builtin
$ type cat
cat is hashed (/usr/bin/cat)
$ type vim
vim is /usr/bin/vim
ls是ls --color=auto的别名cd是 Bash 的内置命令cat是可执行文件/usr/bin/cat,并且已记录到哈希表vim是可执行文件/usr/bin/vim
#相关命令
#推荐阅读
#手册
type: type [-afptP] name [name ...] Display information about command type. For each NAME, indicate how it would be interpreted if used as a command name. Options: -a display all locations containing an executable named NAME; includes aliases, builtins, and functions, if and only if the `-p' option is not also used -f suppress shell function lookup -P force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that would be executed -p returns either the name of the disk file that would be executed, or nothing if `type -t NAME' would not return `file' -t output a single word which is one of `alias', `keyword', `function', `builtin', `file' or `', if NAME is an alias, shell reserved word, shell function, shell builtin, disk file, or not found, respectively Arguments: NAME Command name to be interpreted. Exit Status: Returns success if all of the NAMEs are found; fails if any are not found.