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.


답변

쉘 변수를 환경 변수로 내 보냅니다.


답변

IBM의 예제 자습서 로이 Bash를 참조하십시오 . 사용 예제도 포함합니다 export.