export
In this page:
export
export marks a variable so it's passed down into any child processes the script starts, such as other scripts or programs it calls. Without export, a variable only exists within the current shell and is invisible to subprocesses. This is how scripts share configuration with programs they invoke.
Note: Use export VAR=value when a variable needs to be visible to a program your script calls, not just the script itself.
Example: export
#!/bin/bash
export GREETING="Hello from parent"
bash -c 'echo "Child sees: $GREETING"'
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 13 topics to unlock
0/13 topics done
Complete these topics first: