显示指定命令的类型。
命令语法
type [-afptP] name [name ...]
命令作用
- 显示要查找的命令的信息。
- 管制查找范畴和行为。
- 显示要查找的命令优先级最高的类型。
命令选项
- a:在环境变量PATH中查找并显示所有蕴含name的可执行文件门路;当'-p'选项没有同时给出时,如果在别名、关键字,函数,内建的信息中存在name,则一并显示。
- f:排除对shell函数的查找。
- p:如果name在执行'type -t name'返回的不是'file',那么什么也不返回;否则会在环境变量PATH中查找并返回可执行文件门路。
- P:即便要查找的name是别名、内建、函数中的一个,依然会在环境变量PATH中查找并返回可执行文件门路。
- t:依据name的类型返回一个单词(别名,关键字,函数,内建,文件),否则返回空值。
命令参数
- name:要查找的命令,能够为多个。
命令返回值
当指定的命令能够找到时返回胜利,如果有没找到的返回失败。
接下来要用到的例子假如'~/.bashrc'文件定义了以下的内容:alias ls='ls --color=auto'test123(){ vim ~/.bashrc; }而且执行环境里没有应用enable禁用内建命令。
type -a test123test123 is a functiontest123 (){ vim ~/.bashrc}type -a -f test123bash: type: test123: not foundtype -a -p test123type -a lsls is aliased to `ls --color=suto'ls is /usr/bin/lsls is /bin/lstype -a -p ls/usr/bin/ls/bin/ls
type -p printftype -P printf/usr/bin/printf/bin/printf
type -t lsaliastype -t forkeywordtype -t test123functiontype -t -f test123type -t printfbuiltintype -t chmodfile
留神
- 该命令是 bash 内建命令,相干的帮忙信息请查看
help
命令。 - 命令优先级问题请查看
builtin
命令。
原文链接:https://rumenz.com/rumenbiji/...
微信公众号:入门小站
- 回复【1001】获取 linux常用命令速查手册
- 回复【10010】获取 阿里云ECS运维Linux系统诊断
- 回复【10012】获取 Linux学习笔记【强悍总结值得一看】
- 回复【10013】获取 shell扼要教程