Defining a variable with or without export

后端 未结 14 1488
借酒劲吻你
借酒劲吻你 2020-11-22 09:58

What is export for?

What is the difference between:

export name=value

and

name=value
14条回答
  •  孤街浪徒
    2020-11-22 10:40

    It should be noted that you can export a variable and later change the value. The variable's changed value will be available to child processes. Once export has been set for a variable you must do export -n to remove the property.

    $ K=1
    $ export K
    $ K=2
    $ bash -c 'echo ${K-unset}'
    2
    $ export -n K
    $ bash -c 'echo ${K-unset}'
    unset
    

提交回复
热议问题