最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

linux?type命令用法實戰(zhàn)教程

 更新時間:2023年05月11日 11:04:15   作者:yuxi_o  
type命令用來顯示指定命令的類型,它是Linux系統(tǒng)的一種自省機制,知道了是那種類型,我們就可以針對性的獲取幫助,這篇文章主要介紹了linux?type命令用法實戰(zhàn)教程,需要的朋友可以參考下

在腳本中type可用于檢查命令或函數(shù)是否存在,存在返回0,表示成功;不存在返回正值,表示不成功。

$ type foo >/dev/null 2>&1 || { echo >&2 "I require foo but it's not installed.  Aborting."; exit 1; }

用途說明

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

  • alias 別名
  • keyword 關(guān)鍵字,Shell保留字
  • function 函數(shù),Shell函數(shù)
  • builtin 內(nèi)建命令,Shell內(nèi)建命令
  • file 文件,磁盤文件,外部命令
  • unfound 沒有找到

它是Linux系統(tǒng)的一種自省機制,知道了是那種類型,我們就可以針對性的獲取幫助。比如內(nèi)建命令可以用help命令來獲取幫助,外部命令用man或者info來獲取幫助。

常用參數(shù)

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

type -a可以顯示所有可能的類型,比如有些命令如pwd是shell內(nèi)建命令,也可以是外部命令。

type -p只返回外部命令的信息,相當于which命令。

type -f只返回shell函數(shù)的信息。

type -t 只返回指定類型的信息。

使用示例

示例一 type自己是什么類型的命令

[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

到此這篇關(guān)于linux type命令用法實戰(zhàn)教程的文章就介紹到這了,更多相關(guān)linux type命令內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Linux Shell 常見的命令行格式簡明總結(jié)

    Linux Shell 常見的命令行格式簡明總結(jié)

    這篇文章主要介紹了Linux Shell 常見的命令行格式簡明總結(jié),非常實用,需要的朋友可以參考下
    2014-04-04
  • Shell腳本實現(xiàn)檢測文件是否被修改過代碼分享

    Shell腳本實現(xiàn)檢測文件是否被修改過代碼分享

    這篇文章主要介紹了Shell腳本實現(xiàn)的檢測文件是否被修改代碼分享,其實了解了原理就可以做很多事了,需要的朋友可以參考下
    2014-09-09
  • 慎用rm -rf /與 rm -rf /* 推薦使用mv代替rm

    慎用rm -rf /與 rm -rf /* 推薦使用mv代替rm

    本文主要介紹了慎用rm -rf /與 rm -rf /* 推薦使用mv代替rm,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • shell備份文件、重命名文件、刪除指定文件的3個腳本分享

    shell備份文件、重命名文件、刪除指定文件的3個腳本分享

    這篇文章主要介紹了shell備份文件、重命名文件、刪除指定文件的3個腳本分享,是學習shell時的練習腳本,shell新手朋友可以參考下哦
    2014-07-07
  • 在Linux中查找 IP 地址的3種方法

    在Linux中查找 IP 地址的3種方法

    在 Linux 系統(tǒng)中,經(jīng)常需要查找 IP 地址以進行網(wǎng)絡配置、故障排除或安全管理,無論是查找本地主機的 IP 地址還是查找其他設備的 IP 地址,本文將介紹三種簡單的方法,幫助你在 Linux 中輕松找到所需的 IP 地址,需要的朋友可以參考下
    2023-09-09
  • 使用shell腳本取出服務器圖片的方法

    使用shell腳本取出服務器圖片的方法

    Shell 腳本(shell script),是一種為 shell 編寫的腳本程序。下面通過本文給大家介紹使用shell腳本取出服務器圖片的方法,需要的朋友參考下吧
    2017-12-12
  • 詳解shell腳本[] [[]] -n -z 的含義解析

    詳解shell腳本[] [[]] -n -z 的含義解析

    這篇文章主要介紹了詳解shell腳本[] [[]] -n -z 的含義解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-05-05
  • shell腳本自動安裝jdk的方法示例

    shell腳本自動安裝jdk的方法示例

    這篇文章主要介紹了shell腳本自動安裝jdk的方法示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-12-12
  • expect實現(xiàn)單臺、多臺服務器批量scp傳輸文件

    expect實現(xiàn)單臺、多臺服務器批量scp傳輸文件

    這篇文章主要介紹了expect實現(xiàn)單臺、多臺服務器批量scp傳輸文件,本文提供了單臺傳輸腳本、多臺傳輸腳本及服務器信息配置文件,需要的朋友可以參考下
    2014-12-12
  • Shell腳本中$符號的嵌套使用方法小結(jié)

    Shell腳本中$符號的嵌套使用方法小結(jié)

    在編寫Shell腳本時,通過嵌套使用$符號,間接獲取變量或表達式的值的具體方法,文中根據(jù)實例編碼詳細介紹的十分詳盡,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2023-05-05

最新評論

承德县| 新竹市| 麻栗坡县| 五原县| 高密市| 常熟市| 新巴尔虎右旗| 芦山县| 锡林郭勒盟| 个旧市| 长春市| 深圳市| 桃园县| 平乡县| 鹤庆县| 金华市| 衡南县| 扬中市| 威宁| 肥乡县| 平山县| 北碚区| 团风县| 天等县| 棋牌| 巴楚县| 汽车| 卓资县| 岳普湖县| 大丰市| 钟祥市| 江北区| 新兴县| 兰州市| 山东省| 民丰县| 广平县| 平和县| 伽师县| 绥棱县| 梁平县|