用途说明
type命令用来显示指定命令的类型。一个命令的类型可以是如下几种:
- alias 别名
- keyword 关键字,Shell保留字
- function 函数,Shell函数
- builtin 内建命令,Shell内建命令
- file 文件,磁盘文件,外部命令
- unfound 没有找到
它是Linux系统的一种自省机制,知道了是哪种类型,我们就可以针对性的获取帮助。比如:
内建命令可以用help命令来获取帮助,外部命令用man或者info来获取帮助。
常用参数
type命令的基本使用方式就是直接跟上命令名字。
type -a可以显示所有可能的类型,比如有些命令如pwd是shell内建命令,也可以是外部命令。
type -p只返回外部命令的信息,相当于which命令。
type -f只返回shell函数的信息。
type -t 只返回指定类型的信息。
举个栗子
常用参数举例:
02 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a time |
03 |
time is a shell keyword |
05 |
#2. 返回外部命令的信息,相当于which |
06 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -p time |
08 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -f time |
09 |
time is a shell keyword |
11 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -t time |
备注:
上面time命令的类型有两个,一个是shell保留字,一个是外部命令,那我们查看帮助的方式可以是
01 |
bixiaopeng@bixiaopengtekiMacBook-Pro androidshell$ man time |
04 |
time -- time command execution |
10 |
The time utility executes and times utility. After the utility finishes, |
11 |
time writes the total time elapsed, the time consumed by system overhead, |
12 |
and the time used to execute utility to the standard error stream. Times |
13 |
are reported in seconds. |
18 |
ile: *manpages*, Node: time , Up: ( dir ) |
21 |
bixiaopeng@bixiaopengtekiMacBook-Pro androidshell$ info time |
23 |
TIME(1) BSD General Commands Manual TIME(1) |
26 |
time -- time command execution |
32 |
The time utility executes and times utility. After the utility finishes, |
33 |
time writes the total time elapsed, the time consumed by system overhead, |
34 |
and the time used to execute utility to the standard error stream. Times |
35 |
-----Info:(*manpages*) time ,53 行 --Top------------------------------------- |
36 |
欢迎使用 Info 4.8 版。输入 ? 以获得帮助,m 将得到菜单。 |
常用命令举例:
01 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a ls |
03 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a who |
05 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a cd |
08 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a which |
09 |
which is /usr/bin/which |
10 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a mvn |
11 |
mvn is /usr/share/java/maven-3 .0.3 /bin/mvn |
13 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a adb |
14 |
adb is /Users/bixiaopeng/DevelopSoft/adt-bundle-mac/sdk/platform-tools/adb |
15 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a aapt |
16 |
aapt is /usr/local/bin/aapt |
18 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type grep |
19 |
grep is aliased to ` grep --color=always' |
20 |
bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type awk |
最新文章
- Java基础-一个java文件多个类的问题
- Allegro 快捷键设置
- Python读取文本,输出指定中文(字符串)
- PHPExcel(1.8.0) 帮助代码
- STL数组处理常用函数
- Allegro使用技巧
- AC日记—— codevs 1031 质数环(搜索)
- ie6双边距解决
- C library function - tmpfile()
- LA 3902 Network
- (转)asp.net基础-HttpModule
- Android学习总结——去除标题栏
- hdu1172猜数字(暴力枚举)
- jquery的slideUp、slideDown、slideToggle等涉及滑动效果的一系列函数,在IE浏览器下有几处bug
- OpenGL 的空间变换(上):矩阵在空间几何中的应用
- 【ASP.NET MVC 学习笔记】- 07 使用 Entity Framework
- HTML 使用jQuery选中复选框 简易版
- 关于better-scroll中的问题点
- iOS中 GCD-Grand Central Dispath 多线程 UI_21
- es过滤集提升权重
热门文章
- C++中substr的用法
- Apache Phoenix的序列
- hdoj1005--Number Sequence
- 0.00-050613_ZC_Chapter4_20160119
- openstack-ansible -- 3 Target hosts
- python 矩阵转置transpose
- 离线unity API文档
- java多线程学习二
- Android中字体颜色的设置
- KVM- vnc配置