Category: Advanced – Command Line • Est. reading time: 1 minute
The export command makes a shell variable available to the programs and scripts you run afterward, not just the current shell.
Export a variable
VARIABLE=42
export VARIABLE
# or in one line:
export VARIABLE=42
Add a folder to your PATH
PATH=/path/to/add:$PATH
export PATH
Export a function (bash)
function myfunc() {
echo "In myfunc"
}
export -f myfunc
Note: an export lasts only for the current session. To make it permanent, add the lines to your shell profile, such as ~/.bashrc.
Running your own dedicated or self-managed server? We are glad to help. Reach us at support@allydrez.com or 1-321-209-2004.