共計 1159 個字符,預計需要花費 3 分鐘才能閱讀完成。
自動寫代碼機器人,免費開通
這篇文章將為大家詳細講解有關 Linux 中的 Type 命令怎么用,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
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 打印一個描述命令類型的單詞,該單詞會是下面其中之一:
alias – 別名
builtin – 內置命令
file – 文件
keyword – 關鍵字
這里有一些例子:
Alias
[root@localhost ~]# type -t ls
alias
# 在 Centos 系統中,ls 別名對應的命令是 ls --color=auto[root@localhost bin]# type ls
ls is aliased to `ls --color=auto
Builtin
[root@localhost ~]# type -t printf
builtin
printf 是 shell 內置的命令
File
[root@localhost ~]# type -t awk
file
awk 是可執行的文件
Keyword
[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 命令的類型和位置。
關于“Linux 中的 Type 命令怎么用”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
向 AI 問一下細節
丸趣 TV 網 – 提供最優質的資源集合!
正文完