用途说明
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命令用法_转
转自:http://codingstandards.iteye.com/blog/831504 在脚本中type可用于检查命令或函数是否存在,存在返回0,表示成功:不存在返回正值,表示不成功. $ t ...
- linux type 命令和Linux的五个查找命令
type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命令,Shel ...
- Linux type命令的用法
一般情况下,type命令被用于判断另外一个命令是否是内置命令,但是它实际上有更多的用法. 1.判断一个名字当前是否是alias.keyword.function.builtin.file或者什么都不是 ...
- [转]Linux之type命令
转自:http://codingstandards.iteye.com/blog/831504 用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keywo ...
- linux下的type命令
type命令用来显示指定命令的类型.一个命令的类型可以是如下几种: alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命令,She ...
- 【转】linux之type命令
转自: http://codingstandards.iteye.com/blog/831504 用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keyw ...
- Linux查找命令对比(find、locate、whereis、which、type、grep)
//太长不看版find查找磁盘空间,相较于locate和whereis速度较慢.find和locate的查找单位为文件或者目录,locate其实是find -name的另一种写法.locate和whe ...
- Linux常用命令type、date
Linux命令类型: 内置命令(shell内置):cd is shell builtin 外部命令:命令 is /usr/bin/命令,在文件系统的某个路径下有一个与命令名称相应的可执行文件 type ...
- Linux下命令行安装weblogic10.3.6
Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...
随机推荐
- mybatis动态SQL标签的用法
动态 SQL MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL 语句有多么痛苦.拼接的时候要确保不能忘了必要的空格 ...
- mac上安装opencv3
转载于:http://blog.csdn.net/sanwandoujiang/article/details/51159983 在macosx上安装opencv2 brew tap homebrew ...
- apache 一域名下多个二级域名如何做设置?
域名最新配置说明官网:http://apache.chinahtml.com/ 目的是在根目录,不同子域名可以访问不同目录下的网站: 第一步:打开 C:\Windows\System32\driver ...
- sql基本操作
SQL功能 数据查询 SELECT 数据定义 CREATE, DROP, ALTER 数据操纵 INSERT, UPDATE, DELETE 数据控制 GRANT, REVOKE 创建 ...
- Beaglebone Black – 连接 GY-91 MPU9250+BMP280 九轴传感器(1)
本篇内容为,通过 I2C 配置 GY-91 MPU9250+BMP280 里面的 MPU9250 连接 AK8963 磁感应.两个办法,1)MPU9250 设置 Master Mode 通过 AUX ...
- Statement returned more than one row, where no more than one was expected
Statement returned more than one row, where no more than one was expected <resultMap id="Stu ...
- Java 中的 static 使用之静态变量
大家都知道,我们可以基于一个类创建多个该类的对象,每个对象都拥有自己的成员,互相独立.然而在某些时候,我们更希望该类所有的对象共享同一个成员.此时就是 static 大显身手的时候了!! Java 中 ...
- Vector成员为指针时要注意的问题
vector的复制是浅复制,所以复制一个包含动态内存的变量的对象的话就会出问题. 解决办法:自己写类的复制构造函数,为新对象的指针开辟新的内存空间. 但当vector离开作用域之后,只会把其成员所占的 ...
- 从容而优雅(leisurely and elegant)
每时每刻, 我都变得更好了. ----- 法国心理学家 埃米尔 . 库埃 每时每刻, 我都变得更忙了. ----- 罗伯特 . 西奥迪尼 咬牙切齿的寒风, 昏暗的路灯, 默默的走过那一段从教室到寝 ...
- Database,Uva1592
Peter studies the theory of relational databases. Table in the relational database consists of value ...