首頁>Program>source

tcsh ,我可以使用以下指令碼:

#!/bin/tcsh
setenv X_ROOT /some/specified/path
setenv XDB    ${X_ROOT}/db
setenv PATH   ${X_ROOT}/bin:${PATH}
xrun -d xdb1 -i $1 > $2

相当於 tcsh setenv 在Bash中發挥作用?

有直接的模擬物吗? 環境變數用於查詢可執行檔案。

最新回復
  • 5月前
    1 #

    export VAR=value 將VAR設置為value.如果需要空格,請用單引號將其括起来,例如 export VAR='my val' .如果要對變數进行插值,請使用双引號,例如 export VAR="$MY_OTHER_VAR"

  • 5月前
    2 #

    人们经常建議寫作的原因

    VAR=value
    export VAR
    

    而不是较短的

    export VAR=value
    

    是较长的形式比短形式在更多不同的外壳中工作.如果您知道自己正在与 bash打交道 ,当然两者都可以正常工作。

  • 5月前
    3 #

    在Linux上使用Bash設置本地和環境變數

    Check for a local or environment variables for a variable called LOL in Bash:

    [email protected] /home/el $ set | grep LOL
    [email protected] /home/el $
    [email protected] /home/el $ env | grep LOL
    [email protected] /home/el $
    

    完整性檢查,没有稱為LOL的本地或環境變數。

    Set a local variable called LOL in local, but not environment. So set it:

    [email protected] /home/el $ LOL="so wow much code"
    [email protected] /home/el $ set | grep LOL
    LOL='so wow much code'
    [email protected] /home/el $ env | grep LOL
    [email protected] /home/el $
    

    變數" LOL"存在於區域性變數中,但不存在於環境變數中.如果重新啟動终端,註销/登錄或執行 exec bash,則LOL將消失

    Set a local variable, and then clear out all local variables in Bash

    [email protected] /home/el $ LOL="so wow much code"
    [email protected] /home/el $ set | grep LOL
    LOL='so wow much code'
    [email protected] /home/el $ exec bash
    [email protected] /home/el $ set | grep LOL
    [email protected] /home/el $
    

    You could also just unset the one variable:

    [email protected] /home/el $ LOL="so wow much code"
    [email protected] /home/el $ set | grep LOL
    LOL='so wow much code'
    [email protected] /home/el $ unset LOL
    [email protected] /home/el $ set | grep LOL
    [email protected] /home/el $
    

    本地變數LOL消失了。

    Promote a local variable to an environment variable:

    [email protected] /home/el $ DOGE="such variable"
    [email protected] /home/el $ export DOGE
    [email protected] /home/el $ set | grep DOGE
    DOGE='such variable'
    [email protected] /home/el $ env | grep DOGE
    DOGE=such variable
    

    請註意,匯出使其同時顯示為區域性變數和環境變數。

    上面匯出的變數DOGE在Bash重置後仍然有效:

    [email protected] /home/el $ exec bash
    [email protected] /home/el $ env | grep DOGE
    DOGE=such variable
    [email protected] /home/el $ set | grep DOGE
    DOGE='such variable'
    

    Unset all environment variables:

    您必须拔出一罐Chuck Norris才能重置所有環境變數,而無需註销/登錄:

    [email protected] /home/el $ export CAN="chuck norris"
    [email protected] /home/el $ env | grep CAN
    CAN=chuck norris
    [email protected] /home/el $ set | grep CAN
    CAN='chuck norris'
    [email protected] /home/el $ env -i bash
    [email protected] /home/el $ set | grep CAN
    [email protected] /home/el $ env | grep CAN
    

    您建立了一个環境變數,然後重置终端以删除它们。

    Or you could set and unset an environment variable manually like this:

    [email protected] /home/el $ export FOO="bar"
    [email protected] /home/el $ env | grep FOO
    FOO=bar
    [email protected] /home/el $ unset FOO
    [email protected] /home/el $ env | grep FOO
    [email protected] /home/el $
    

  • 5月前
    4 #

    VAR=value 將VAR設置為值。

    在那之後 也会將其提供给子程序。

    export VAR 是两者的簡寫。

  • 5月前
    5 #

    我认為您正在尋找 export VAR=value -尽管我可能錯了..我以前从未玩過tcsh.使用以下語法:

    export
    
    export VARIABLE=value

  • MySQL select語句是CASE還是IF ELSEIF? 不確定如何获得結果
  • java:URLConnectionsetDoOutput()究竟会影响什麼?