4 回答

TA貢獻(xiàn)1797條經(jīng)驗 獲得超6個贊
source命令用法:
source FileName
作用:在當(dāng)前bash環(huán)境下讀取并執(zhí)行FileName中的命令。
注:該命令通常用命令“.”來替代。
如:source .bash_rc 與 . .bash_rc 是等效的。
注意:source命令與shell scripts的區(qū)別是,
source在當(dāng)前bash環(huán)境下執(zhí)行命令,而scripts是啟動一個子shell來執(zhí)行命令。這樣如果把設(shè)置環(huán)境變量(或alias等等)的命令寫進(jìn)scripts中,就只會影響子shell,無法改變當(dāng)前的BASH,所以通過文件(命令列)設(shè)置環(huán)境變量時,要用source 命令。

TA貢獻(xiàn)1880條經(jīng)驗 獲得超4個贊
這是bash的內(nèi)置指令。
source filename [argements]
Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.
添加回答
舉報