shell命令分類

linux的shell命令總共分為5中,alias,function,file,builtin,keyword。

alias就是別名,function就是自己創(chuàng)建的shell函數(shù),file就是path路徑里的一些二進(jìn)制或者其他sh文件等掛在硬盤上的文件,keyword就是shell的關(guān)鍵字。

可以通過type -t command來查看,另外如果一個(gè)命令是file的話,可以通過type -p command查看該命令的絕對(duì)路徑..。

關(guān)于一個(gè)命令的運(yùn)行到底有沒有開辟新的進(jìn)程,我們可以通過一種方法查看,首先運(yùn)行該命令,然后ps -elf | grep一下就可以了,可以肯定的是file類型的command肯定是在子進(jìn)程中運(yùn)行的,但是builtin就不好說了,我man type一下:


Shell builtin commands are commands that can be executed within the running shell's process.? Note that, in the case of csh(1) builtin commands, the command is executed in a sub-

?? ? shell if it occurs as any component of a pipeline except the last.


?? ? If a command specified to the shell contains a slash ``/'', the shell will not execute a builtin command, even if the last component of the specified command matches the name of

?? ? a builtin command.? Thus, while specifying ``echo'' causes a builtin command to be executed under shells that support the echo builtin command, specifying ``/bin/echo'' or

?? ? ``./echo'' does not.

上面說的很清楚,第一段的意思是builtin命令可以在當(dāng)前shell中運(yùn)行,但是在csh中,如果在使用管道的時(shí)候內(nèi)建命令不是在最后面,就會(huì)在子進(jìn)程中運(yùn)行。第二段的意思是如果使用絕對(duì)路徑或者相對(duì)路徑使用命令,即使最終引用的命令和builtin命令一樣,也會(huì)在子進(jìn)程中運(yùn)行,相當(dāng)于file類型的了。

阿里云雙十一云服務(wù)器拼團(tuán)活動(dòng),已經(jīng)打到最低價(jià)99元一年!有需要的可以考慮一波了!

https://m.aliyun.com/act/team1111/#/share?params=N.9g4CZ2TwSh.qilw7y0a

---------------------

作者:pysta

來源:CSDN

原文:https://blog.csdn.net/Yvlen/article/details/79254439

版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請(qǐng)附上博文鏈接!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 官網(wǎng) 中文版本 好的網(wǎng)站 Content-type: text/htmlBASH Section: User ...
    不排版閱讀 4,695評(píng)論 0 5
  • 為何叫做 shell ? shell prompt(PS1) 與 Carriage Return(CR) 的關(guān)系?...
    Zero___閱讀 3,314評(píng)論 3 49
  • bash:Bourne Again shell,是 Linux 上的標(biāo)配 shell;對(duì)于想學(xué)習(xí) shell 的人...
    michael_jia閱讀 1,521評(píng)論 0 4
  • 一、Python簡(jiǎn)介和環(huán)境搭建以及pip的安裝 4課時(shí)實(shí)驗(yàn)課主要內(nèi)容 【Python簡(jiǎn)介】: Python 是一個(gè)...
    _小老虎_閱讀 6,313評(píng)論 0 10
  • 《紅顏舊》是大名鼎鼎的電視劇瑯琊榜中的插曲。初看,歌名加之哀怨婉轉(zhuǎn)的起調(diào)“西風(fēng)夜渡寒山雨”略有“十里平湖霜滿天,寸...
    土土動(dòng)人閱讀 1,402評(píng)論 2 1

友情鏈接更多精彩內(nèi)容