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

Let's consider a BASH shell script named that contains a variable named HW that contains the text Hello World

HW="Hello World"


There will be no output when issuing the echo $hw command.

[user1@server1 ~]# echo $hw


The source command is used to tell your shell to use your script. Instead of using the word source, just a single period can be used as well.

[user1@server1 ~]# source
[user1@server1 ~]# .


Now, echo $hw will produce Hello World.

[user1@server1 ~]# echo $hw
Hello World



Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |