Bootstrap FreeKB - Linux Commands - source (export variable)
Linux Commands - source (export variable)

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 88d0d5 in the box below so that we can be sure you are a human.