คำสั่งส่งออกที่ควรทำใน Linux คืออะไร?
คำสั่งส่งออกที่ควรทำใน Linux คืออะไร?
คำตอบ:
นี่คือตัวอย่างที่แสดงให้เห็นถึงพฤติกรรม
$ # 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กระบวนการทุบตีใหม่ที่คุณสร้างขึ้นจะไม่สามารถมองเห็นtestvarได้ เมื่อtestvarถูกส่งออกกระบวนการใหม่ก็สามารถมองเห็นtestvarได้
ส่งออกตัวแปรเชลล์เป็นตัวแปรสภาพแวดล้อม
manหน้านี้แล้วหรือยัง ss64.com/bash/export.html
โปรดดูBashนี้ตามตัวอย่างการสอนจาก IBM exportมันยังรวมถึงตัวอย่างของการใช้