type 顯示命令的型別

2021-06-20 05:37:08 字數 2957 閱讀 6299

type命令用來顯示指定命令的型別。乙個命令的型別可以是如下之一

它是linux系統的一種自省機制,知道了是那種型別,我們就可以針對性的獲取幫助。比如內建命令可以用help命令來獲取幫助,外部命令用man或者info來獲取幫助。

type命令的基本使用方式就是直接跟上命令名字。

type -a可以顯示所有可能的型別,比如有些命令如pwd是shell內建命令,也可以是外部命令。

type -p只返回外部命令的資訊,相當於which命令。

type -f只返回shell函式的資訊。

type -t 只返回指定型別的資訊。

[root@new55 ~]# type -a type

type is a shell builtin

[root@new55 ~]# help type

type: type [-afptp] name [name ...]

for each name, indicate how it would be interpreted if used as a

command name.

if the -t option is used, `type' outputs a single word which is one of

`alias', `keyword', `function', `builtin', `file' or `', if name is an

alias, shell reserved word, shell function, shell builtin, disk file,

or unfound, respectively.

if the -p flag is used, `type' either returns the name of the disk

file that would be executed, or nothing if `type -t name' would not

return `file'.

if the -a flag is used, `type' displays all of the places that contain

an executable named `file'.  this includes aliases, builtins, and

functions, if and only if the -p flag is not also used.

the -f flag suppresses shell function lookup.

the -p flag forces a path search for each name, even if it is an alias,

builtin, or function, and returns the name of the disk file that would

be executed.

typeset: typeset [-affirtx] [-p] name[=value] ...

obsolete.  see `declare'.

[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 ~]#

type命令及Linux命令型別

type後跟乙個指令,會展示當該指令作為乙個命令時是如何解讀的。引數 a,type會列印指令的所有位置。引數 t,type會列印alias,keyword,function,builtin,file的之一。alias 別名。keyword shell保留字。function shell函式。buil...

Linux命令型別和執行順序 type命令

type命令 用來顯示指定命令的型別,判斷給出的指令是內部指令還是外部指令。type檢視的linux中的命令型別 alias 別名。keyword 關鍵字,shell保留字。function 函式,shell函式。builtin 內建命令,shell內建命令。file 檔案,磁碟檔案,外部命令。un...

result中的type型別

1 dispatcher 它是預設的,用來轉向頁面,通常處理jsp 2 redirect 將使用者重定向到乙個已配置好的url 3 redirectaction 將使用者重定向到乙個已定義好的action 5 freemarker 呈現freemarker模板 6 httpheader 返回乙個已配...