用途说明
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系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...
随机推荐
- MySQL中select * for update锁表的问题
MySQL中select * for update锁表的问题 由于InnoDB预设是Row-Level Lock,所以只有「明确」的指定主键,MySQL才会执行Row lock (只锁住被选取的资料例 ...
- C# 的Brush 及相关颜色的操作 (并不是全转)
C# 的Brush 及相关颜色的操作 2013-12-13 14:08 4977人阅读 评论(0) 收藏 ...
- SQL SERVER数据库的表中修改字段属性被阻止“Prevent saving changes that require table re-creation”
1.启动SQL SERVER,选择工具—>选项,去掉“ 阻止保存要求重新创建表的更改”前面的勾. 2.选择设计器 3.去掉“阻止保存要求重新创建表的更改”前面的对号,点击OK. 重新启动SQL ...
- [Machine-Learning] 熟悉 Numpy
Numpy 是 Python 中的一个模块,主要用于处理数学和计算相关的问题,这里是一个入门的介绍. 导入 习惯上可以这样导入: import numpy as np 在 machine learni ...
- php实战正则表达式:验证手机号
摘自http://www.tuicool.com/articles/MFNZRzu 本文通过逐步完善一个验证手机号的正则表达式来介绍了正则表达式中的 字符组 .量词 . 字符串起始/结束位置 . 分组 ...
- [转](二)unity4.6Ugui中文教程文档-------概要-UGUI Canvas
大家好,我是孙广东. 转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unityma ...
- .NET IL学习笔记(一)
参考资料: 1. <.NET IL Assembler> 2. NGEN代码产生器 3. NGEN的使用 4. IL编辑器下载 5. IL编辑器的使用 知识点: ● Common Lang ...
- jdom xml解析
import org.jdom.Document; import org.jdom.Element; import org.jdom.input.SAXBuilder; import org.xml. ...
- Delphi名站以及高手Blog
以前知道的: http://cnblogs.com/del (万一兄的,这个不用解释了) http://www.cnblogs.com/del/archive/2010/04/25/1720750.h ...
- [Selenium] 数字显示的月份转换为英文显示
如果只需要英文的前三位字母,可以自己截取.