用途说明

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 只返回指定类型的信息。

举个栗子

常用参数举例:

01 #1. 显示所有可能的类型
02 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a time
03 time is a shell keyword
04 time is /usr/bin/time
05 #2. 返回外部命令的信息,相当于which
06 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -p time
07 #3. 只返回shell函数信息
08 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -f time
09 time is a shell keyword
10 #4. 只返回指定的类型
11 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -t time
12 keyword

备注:

上面time命令的类型有两个,一个是shell保留字,一个是外部命令,那我们查看帮助的方式可以是

01 bixiaopeng@bixiaopengtekiMacBook-Pro androidshell$ man time
02   
03 NAME
04      time -- time command execution
05  
06 SYNOPSIS
07      time [-lp] utility
08  
09 DESCRIPTION
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.
14  
15      Available options:
16  
17  
18 ile: *manpages*,  Node: time,  Up: (dir)
19  
20  
21 bixiaopeng@bixiaopengtekiMacBook-Pro androidshell$ info time
22  
23 TIME(1)                   BSD General Commands Manual                  TIME(1)
24  
25 NAME
26      time -- time command execution
27  
28 SYNOPSIS
29      time [-lp] utility
30  
31 DESCRIPTION
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
02 ls is /bin/ls
03 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a who
04 who is /usr/bin/who
05 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type -a cd
06 cd is a shell builtin
07 cd is /usr/bin/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
12 mvn is /usr/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
17  
18 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type grep
19 grep is aliased to `grep --color=always'
20 bixiaopeng@bixiaopengtekiMacBook-Pro ~$ type awk
21 awk is /usr/bin/awk 

Linux type命令的更多相关文章

  1. linux type命令用法_转

    转自:http://codingstandards.iteye.com/blog/831504 在脚本中type可用于检查命令或函数是否存在,存在返回0,表示成功:不存在返回正值,表示不成功. $ t ...

  2. linux type 命令和Linux的五个查找命令

    type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命令,Shel ...

  3. Linux type命令的用法

    一般情况下,type命令被用于判断另外一个命令是否是内置命令,但是它实际上有更多的用法. 1.判断一个名字当前是否是alias.keyword.function.builtin.file或者什么都不是 ...

  4. [转]Linux之type命令

    转自:http://codingstandards.iteye.com/blog/831504 用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keywo ...

  5. linux下的type命令

    type命令用来显示指定命令的类型.一个命令的类型可以是如下几种: alias 别名 keyword 关键字,Shell保留字 function 函数,Shell函数 builtin 内建命令,She ...

  6. 【转】linux之type命令

    转自: http://codingstandards.iteye.com/blog/831504 用途说明 type命令用来显示指定命令的类型.一个命令的类型可以是如下之一 alias 别名 keyw ...

  7. Linux查找命令对比(find、locate、whereis、which、type、grep)

    //太长不看版find查找磁盘空间,相较于locate和whereis速度较慢.find和locate的查找单位为文件或者目录,locate其实是find -name的另一种写法.locate和whe ...

  8. Linux常用命令type、date

    Linux命令类型: 内置命令(shell内置):cd is shell builtin 外部命令:命令 is /usr/bin/命令,在文件系统的某个路径下有一个与命令名称相应的可执行文件 type ...

  9. Linux下命令行安装weblogic10.3.6

    Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...

随机推荐

  1. 使用cygwin出现syntax error near unexpected token'$'do\r

    直接从csdn复制粘贴的.sh代码,放到cygwin下运行sh的时候出错syntax error near unexpected token'$'do\r 解决方法: 1.下载notepad++ 2. ...

  2. html5+css3 微信开发-学习实例

    例子1.控制数据只显示两行并且最后使用省略号 样式如下: .ControlDataRows{ overflow : hidden; text-overflow: ellipsis; display: ...

  3. [Android Studio] 按钮学习

    Android Studio 按钮 1. 添加一个按钮 新建一个 Blank Project 之后, 在 activity_main.xml: 中添加一个按钮, 可以使用design 模式来添加,: ...

  4. IntelliJ IDEA使用(1)——IDEA配置JDK

    提前安装jdk,配置环境变量 一.配置jdk 1.依次点开File -->Project Structure,点击左侧标签页,点击SDKs 2.点击+号,选SDK 3.在弹出框选择jdk路径(我 ...

  5. 原创开源项目HierarchyViewer for iOS 2.1 Beta新功能介绍

    回顾 HierarchyViewer for iOS是我们发布的一个开源项目,采用GPL v3.0协议. HierarchyViewer for iOS可以帮助iOS应用的开发和测试人员,在没有源代码 ...

  6. ASP.Net系列教程

    Getting Started with ASP.NET MVC This is a beginner tutorial that introduces the basics of ASP.NET M ...

  7. Install Google Pinyin on Ubuntu 14.04

    Install Google Pinyin on Ubuntu 14.04 I've been spending more and more time on Ubuntu and I'm not us ...

  8. SAP的物料归档

    我们在对前台对物料进行删除时,是物理删除,也就是打个删除标志,并没有正真的从数据库里删除,在前台还是可以看到的,下面介绍一下SAP的归档处理可以 把已删除的物料在前台删除掉,注意:项目里根据情况得到领 ...

  9. @Scheduled 注解

    Spring配置文件xmlns加入 <!---加入:xmlns:task="http://www.springframework.org/schema/task"--> ...

  10. [转]jQuery.validate插件在失去焦点时执行验证代码

    转:http://my.oschina.net/enyo/blog/311566 关于 jquery.validate.js 表单验证插件如何在失去焦点时做验证.看手册后发现默认是在表单提交时执行验证 ...