Linux type命令的使用方法
来源:互联网 发布:mac文件夹加密 编辑:程序博客网 时间:2024/04/29 22:15
用途说明
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 只返回指定类型的信息。
使用示例
示例一 type自己是什么类型的命令
[root@new55 ~]# type -a type
type is a shell builtin
[root@new55 ~]# help type
type: type [-afptP] name [name ...]
typeset: typeset [-afFirtx] [-p] name[=value] ...
[root@new55 ~]#
示例二 常见命令的类型
[root@new55 ~]# type -a cd
cd is a shell builtin
[root@new55 ~]# type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
[root@new55 ~]# type -a time
time is a shell keyword
time is /usr/bin/time
[root@new55 ~]# type -a date
date is /bin/date
[root@new55 ~]# type -a which
which is aliased to `alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
which is /usr/bin/which
[root@new55 ~]# type -a whereis
whereis is /usr/bin/whereis
[root@new55 ~]# type -a whatis
whatis is /usr/bin/whatis
[root@new55 ~]# type -a function
function is a shell keyword
[root@new55 ~]# type -a ls
ls is aliased to `ls --color=tty'
ls is /bin/ls
[root@new55 ~]# type -a ll
ll is aliased to `ls -l --color=tty'
[root@new55 ~]# type -a echo
echo is a shell builtin
echo is /bin/echo
[root@new55 ~]# type -a bulitin
-bash: type: bulitin: not found
[root@new55 ~]# type -a builtin
builtin is a shell builtin
[root@new55 ~]# type -a keyword
-bash: type: keyword: not found
[root@new55 ~]# type -a command
command is a shell builtin
[root@new55 ~]# type -a alias
alias is a shell builtin
[root@new55 ~]# type -a grep
grep is /bin/grep
[root@new55 ~]#
- Linux type命令的使用方法
- Linux下的type命令
- linux type命令-显示命令的类型
- linux的ln命令使用方法
- Linux man命令的使用方法
- Linux man命令的使用方法
- linux命令is的使用方法
- Linux mount命令的使用方法
- Linux man命令的使用方法
- linux 的 chown 命令使用方法
- Linux 的echo命令使用方法
- Linux man命令的使用方法
- Linux man命令的使用方法
- Linux man命令的使用方法
- Linux mount命令的使用方法
- Linux ftp命令的使用方法
- Linux man命令的使用方法
- Linux man命令的使用方法
- 整合SSH步骤,版本:Strust2.3+Spring3.2+Hibernate3.6
- 如何测试你自己的 RubyGem?
- 2012年5月SAT香港真题解析
- 从头到尾彻底理解KMP
- 写日志可以加分吗
- Linux type命令的使用方法
- C++指针和二维数组
- 走进Struts2(六)— 文件上传和下载
- 黑马-OC语法-Foundation-常用结构体
- OpenCV HOGDescriptor 参数图解
- 审美、效用与情感——关于icon和Logo设计的一些想法
- GRE写作必备句型
- App市场观察:改变用户行为的App却改变不了用户行为
- iSCSI技术