Apa yang harus dilakukan perintah ekspor di Linux?
Apa yang harus dilakukan perintah ekspor di Linux?
Jawaban:
Berikut adalah contoh untuk menunjukkan perilaku tersebut.
$ # 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'
Anda akan melihat bahwa tanpa exportproses bash baru yang Anda buat tidak dapat dilihat testvar. Ketika testvardiekspor, proses baru dapat melihat testvar.
Ekspor variabel shell sebagai variabel lingkungan.
manhalaman tersebut? ss64.com/bash/export.html
Silakan lihat tutorial Bash ini dengan contoh dari IBM. Bahkan termasuk contoh penggunaan export.