在指令碼中使用export匯出變數值

來源:互聯網
上載者:User

標籤:

LD_LIBRARY_PATH環境變數可以用於設定Linux動態庫的位置,常見的用法如export LD_LIBRARY_PATH=/home/username/foo:$LD_LIBRARY_PATH[1],但是每次都輸入一長串的路徑多少有些麻煩,用shell來執行是不錯的方式。

首先將export命令儲存至export.sh檔案,然後將檔案修改為可執行許可權,最後運行 source export.sh[2]即可。由於子shell對變數的修改無法影響到父shell,因此需要採用source或者.執行,而不是直接運行./export.sh[2]。

 

[1]Shared libraries with GCC on Linux - Cprogramming.com

[2]shell - How can I make variables "exported" in a bash script stick around? - Unix & Linux Stack Exchange

在指令碼中使用export匯出變數值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.