您好,登錄后才能下訂單哦!
這篇文章主要介紹shell中bash、sh、./、source的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
sh 和 bash
GNU/Linux 操作系統(tǒng)中的 /bin/sh 本是 bash (Bourne-Again Shell) 的符號(hào)鏈接,但鑒于 bash 過于復(fù)雜,有人把 bash 從 NetBSD 移植到 Linux 并更名為 dash (Debian Almquist Shell),并建議將 /bin/sh 指向它,以獲得更快的腳本執(zhí)行速度。Dash Shell 比 Bash Shell 小的多,符合POSIX標(biāo)準(zhǔn)。
1. ubuntu Linux localhost 4.4.0-105-generic #128-Ubuntu SMP Thu Dec 14 12:42:11 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux xhx@localhost:~$ ls -la /bin/sh lrwxrwxrwx 1 root root 4 Aug 17 2017 /bin/sh -> dash 2. centos [root@xuhx-02 bin]# uname -a Linux xuhx-02 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux [root@xuhx-02 bin]# ls -la sh lrwxrwxrwx. 1 root root 4 6月 25 16:52 sh -> bash
sh/bash 和 source
sh/bash 是打開子shel,在子shell 中運(yùn)行,在子shell 設(shè)置的環(huán)境變量不會(huì)影響到父shell;
source 是在當(dāng)前shell 中運(yùn)行,因此修改完環(huán)境變量需要運(yùn)行source /etc/profile 使其生效 而不是使用sh/bash命令;source = .;
./ 需要對(duì)執(zhí)行的腳本有r和x權(quán)限
[root@xuhx-02 ~]# sh t.sh anaconda-ks.cfg hello n2n newdir1 pytho.py rpmbuild sort test.sh t.sh ttttt.sh [root@xuhx-02 ~]# bash t.sh anaconda-ks.cfg hello n2n newdir1 pytho.py rpmbuild sort test.sh t.sh ttttt.sh [root@xuhx-02 ~]# ./t.sh -bash: ./t.sh: 權(quán)限不夠 [root@xuhx-02 ~]# source t.sh anaconda-ks.cfg hello n2n newdir1 pytho.py rpmbuild sort test.sh t.sh ttttt.sh [root@xuhx-02 ~]# . t.sh anaconda-ks.cfg hello n2n newdir1 pytho.py rpmbuild sort test.sh t.sh ttttt.sh
以上是“shell中bash、sh、./、source的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。