用途说明
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 |
- Linux type命令
用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下几种: alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命 ...
- linux type命令用法_转
转自:http://codingstandards.iteye.com/blog/831504 在脚本中type可用于检查命令或函数是否存在,存在返回0,表示成功:不存在返回正值,表示不成功. $ t ...
- [转]Linux之type命令
转自:http://codingstandards.iteye.com/blog/831504 用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keywo ...
- linux下的type命令
type命令用来显示指定命令的类型.一个命令的类型可以是如下几种: alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命令,She ...
- linux type 命令和Linux的五个查找命令
type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命令,Shel ...
- type命令详解
转自:http://codingstandards.iteye.com/blog/831504 在脚本中type可用于检查命令或函数是否存在,存在返回0,表示成功:不存在返回正值,表示不成功. $ t ...
- Linux type命令的用法
一般情况下,type命令被用于判断另外一个命令是否是内置命令,但是它实际上有更多的用法. 1.判断一个名字当前是否是alias.keyword.function.builtin.file或者什么都不是 ...
- 【转】linux之type命令
转自: http://codingstandards.iteye.com/blog/831504 用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keyw ...
- type 命令详解
type 作用: 用来显示指定命令的类型,判断出命令是内部命令还是外部命令. 命令类型: alias: 别名 keyword:关键字, shell 保留字 function:函数, shell函数 ...
随机推荐
- python中threading多线程
python中有两个处理多线程的模块thread和threading.其中thread提供了多线程底层支持的模块,以低级原始的发那个是来处理和控制线程,使用起来较为复杂:而threading基于thr ...
- 关于IIntelliJ IDEA(2017)安装和破解
一.下载并安装, IntelliJ IDEA的官网:https://www.jetbrains.com 二.破解. 百度下载一个 JetbrainsCrack-2.6.2.jar 破解补丁.放在你的安 ...
- HDFS存档
Hadoop存档 每个文件均按块方式存储,每个块的元数据存储在namenode的内存中,因此Hadoop存储小文件会非常低效.因为大量的小文件会耗尽namenode中的大部分内存.存储小文件所需的磁盘 ...
- Windows下MetaMap工具安装
Windows下MetaMap工具安装 一.Main MetaMap安装 Prerequisties 12G磁盘空间 JAVA6 or newer JRE or SDK installed Downl ...
- Guest CPU model configuration in libvirt with QEMU/KVM
每个hypervisor对于guest能看到的cpu model定义都不同,Xen 提供host pass through,所以guest能看到的cpu和host完全相同. QEMU/KVM中gues ...
- npm全局安装
时间长了,很多东西都忘了. 全局安装以后,在你自己的电脑任何位置都可以使用的包.直接用命令使用的: 比如:supervisor mok 还有cnpm,express之类的.gulp之类的. 剩下的我们 ...
- VS2010 + QT 5 +open inventor 环境配置
本科毕业设计做的是 随钻测量的井眼轨迹和测井曲线的三维显示 要求的环境是 QT + Open Inventor 在寒假开学前,打算将环境配置好,开学后再正式编码实现,可是....环境也 ...
- windows live writer 设置默认字体
下载 Text Template 插件 设置默认字体添加模版. <p style="padding-bottom: 0px; line-height: 130%; margin-t ...
- poj2289二分图多重匹配
题意:给你一张二分图,求右边点到汇点的最小容量(保证流量为n)是多少 题解:二分答案,每次重新建边跑最大流,看是不是为n就好了 #include<map> #include<set& ...
- HDU 1711 kmp+离散化
http://acm.hdu.edu.cn/showproblem.php?pid=1711 Number Sequence Time Limit: 10000/5000 MS (Java/Other ...