Linux Commands - source (export variable)
by
Jeremy Canfield |
Updated: February 02 2023
| Linux Commands articles
Let's consider a BASH shell script named example.sh that contains the following.
#!/bin/bash
GREETING="Hello World"
Running the script and then attempting to echo $GREETING will produce no output.
~]# bash example.sh
~]# echo $GREETING
The source command can be used make the variables set in the script available in your shell.
~]# source example.sh
Or, just a single period can be used.
~]# . example.sh
Now, echo $GREETING should produce output.
~]# echo $GREETING
Hello World
Did you find this article helpful?
If so, consider buying me a coffee over at