type
进程与系统
用法
type [-a] <name>直接问 shell 某个名字到底是什么——别名、函数、内建还是文件,这正是只看 PATH 的 `which` 看不到的部分。
常用选项
| 选项 | 含义 |
|---|---|
| -a | Every meaning of the name, in the order the shell would consider them. |
| -t | One word only: alias, keyword, function, builtin or file. |
| -P | Force a PATH lookup even if the name is also an alias or function (bash). |
| -f | Ignore shell functions. |
示例
type -a lsReveals the alias first and the /bin/ls binary second.
type -t rmPrints "file" if nothing is shadowing it, "alias" if something is.
看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. type 是做什么的?
直接问 shell 某个名字到底是什么——别名、函数、内建还是文件,这正是只看 PATH 的 `which` 看不到的部分。
Q. 怎么写?
type [-a] <name> —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 4 个,完整列表在 man type。这条命令属于进程与系统。
相关命令
man 手册: man type