Linuxで行うはずのexportコマンドとは何ですか?
Linuxで行うはずのexportコマンドとは何ですか?
回答:
これは動作を示す例です。
$ # set testvar to be a value
$ testvar=asdf
$ # demonstrate that it is set in the current shell
$ echo $testvar
$ # create a bash subprocess and examine the environment.
$ bash -c "export | grep 'testvar'"
$ bash -c 'echo $testvar'
$ # export testvar and set it to the a value of foo
$ export testvar=foo
$ # create a bash subprocess and examine the environment.
$ bash -c "export | grep 'testvar'"
declare -x testvar="foo"
$ bash -c 'echo $testvar'
foo
$ # mark testvar to not be exported
$ export -n testvar
$ bash -c "export | grep 'testvar'"
$ bash -c 'echo $testvar'
あなたはなしということに気づくでしょうexport、あなたが作成した新しいbashのプロセスを参照することができませんでしたtestvar。testvarがエクスポートされたとき、新しいプロセスはを見ることができましたtestvar。
シェル変数を環境変数としてエクスポートします。
manページを試しましたか?ss64.com/bash/export.html