環境變數  
   
環境變數和使用者變數相似,只不過此種變數會將其值傳給其子程序 (subshell)所執行的命令。 所以一個子程序會繼承所有父程序的環境變數。 一個shell script 可以用 export 指令將一個普通的使用者變數變成 環境變數,不但該程序可以用到,其所衍生的子程序也都可以用到。 等到該程序結束,所有定義的環境變數將被清除,不再存在。
 
 
export 宣告環境變數

 
   
在原始 Bouorne Shell 中,必須分兩步驟進行:
name=Clinton
export name

PATH=$PATH:/usr/local/bin 
export PATH 
 
   
在 POSIX標準中,只需一個步驟即可:
export name=Clinton
export PATH=$PATH:/usr/local/bin
 
 
列出所有環境變數
$ export -p   #Print current environment 
 
 
Add variables to a program's environment without permanently affecting the environment of the shell or subsequent commands.

  PATH=/bin:/usr/bin awk '...' file1 file2

This changes the value of PATH only for the execution of the single awk command. Any subsequent commands, however, see the current value of PATH in their environment.
Man Page of 'export'
Web Page Copyright: 亞洲大學資訊電機學院 連耀南 yaonanlien@asia.edu.tw  env0.htm,  Thu Sep 7 16:18:51 CST 2023