温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

linux系统中如何使用type命令

发布时间:2022-02-18 13:42:17 来源:亿速云 阅读:184 作者:小新 栏目:开发技术

这篇文章主要为大家展示了“linux系统中如何使用type命令”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“linux系统中如何使用type命令”这篇文章吧。

type命令 用来显示指定命令的类型,判断给出的指令是内部指令还是外部指令。

linux系统中如何使用type命令

如何使用type命令

type命令是bash内置,type语法:

type [-afptP] [name ...]

例如,查看type的类型:

[root@localhost ~]# type typetype is a shell builtin

也可以提供多个参数:

[root@localhost ~]# type vim sleep headvim is hashed (/usr/bin/vim)
sleep is /usr/bin/sleep
head is /usr/bin/head

命令的类型

-t选项告诉type打印一个描述命令类型的单词,该单词会是下面其中之一:

  • alias – 别名
  • builtin – 内置命令
  • file – 文件
  • keyword – 关键字

这里有一些例子:

Alias
[root@localhost ~]# type -t lsalias# 在Centos系统中,ls别名对应的命令是ls --color=auto[root@localhost bin]# type lsls is aliased to `ls --color=auto'
Builtin
[root@localhost ~]# type -t printfbuiltin

printf是shell内置的命令

File
[root@localhost ~]# type -t awkfile

awk是可执行的文件

Keyword
[root@localhost ~]# type -t whilekeyword

while、for、if、else……等等,是Bash中保留的关键字

显示命令的位置和类型

使用-a命令可以显示命令的位置和类型:

[root@localhost ~]# type -a ls printf awk whilels is aliased to `ls --color=auto'
ls is /usr/bin/ls
printf is a shell builtin
printf is /usr/bin/printf
awk is /usr/bin/awk
while is a shell keyword

这个实例执行后显示了ls,printf,awk,while命令的类型和位置。

以上是“linux系统中如何使用type命令”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI