[英]How to add export statement in a bash_profile file?
我試圖了解如果我必須添加export語句來設置bash_profile文件中的變量。 我該怎么辦? 例如,如果我必須添加導出AX ='name',那么我應該只在文件末尾寫入它還是我還需要編寫其他任何內容
只需在~/.bash_profile
文件中export AS='name'
任何位置寫出export AS='name'
:
# Append to the end of the file
$ echo "export AS='name'" >> ~/.bash_profile
# Update shell
$ source ~/.bash_profile
第一個命令將所需的行添加到文件中(或者只使用文本編輯器) ,第二個命令使用新變量更新shell。
有兩種情況:
1.導出自變量
例如,如果要獨立導出變量“AX”,請使用:
AX = 'name'
export AX
2.導出一個自變量,然后將其附加到某個現有變量
例如,如果要單獨導出變量“AX”,然后將其附加到類路徑,則使用:
AX = 'name'
export AX
PATH=$PATH:AX
export PATH
通常,變量在一個地方聲明和定義,並在另一個地方導出:
AX='name'
export AX
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.