¿Qué se supone que debe hacer el comando de exportación en Linux?
9
Aquí hay un ejemplo para demostrar el comportamiento.
$ # 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'
Notarás que sin exportel nuevo proceso bash que creaste no se pudo ver testvar. Cuando testvarse exportó, el nuevo proceso pudo ver testvar.
Exportar una variable de shell como variable de entorno.
manpágina? ss64.com/bash/export.htmlConsulte este tutorial Bash by example de IBM. Incluso incluye un ejemplo de uso
export.fuente