首页 > Linux操作系统 > Linux操作系统 > Linux中Type命令如何使用
type工具用于显示
命令的类型信息。它将展示在
命令行上输入给定的命令将如何解释。 |
type命令是bash内置,type语法:
type [-afptP] [name ...]
例如,查看
type的类型:
[root@localhost ~]# type type type is a shell builtin
也可以提供多个参数:
[root@localhost ~]# type vim sleep head vim is hashed (/usr/bin/vim) sleep is /usr/bin/sleep head is /usr/bin/head
-t选项告诉type打印一个描述命令类型的单词,该单词会是下面其中之一:
这里有一些例子:
[root@localhost ~]# type -t ls alias # 在Centos系统中,ls别名对应的命令是ls --color=auto[root@localhost bin]# type ls ls is aliased to `ls --color=auto'
[root@localhost ~]# type -t printf builtin
printf是shell内置的命令
[root@localhost ~]# type -t awk file
awk是可执行的文件
[root@localhost ~]# type -t while keyword
while、for、if、else……等等,是Bash中保留的关键字
使用
-a命令可以显示命令的位置和类型:
[root@localhost ~]# type -a ls printf awk while ls 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命令的类型和位置。
type工具用于显示命令的类型信息。它将展示在命令行上输入给定的命令将如何解释。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31559985/viewspace-2705867/ ,如需转载,请注明出处,否则将追究法律责任。