Source

From LinuxIntro
Jump to: navigation, search

source is a command to execute a script and set environment variables from it. Normally when a script is run it gets its own environment and can only modify variables within that. With the command source the modifications get applied to the context of the calling program. Example:

hello.sh
export hello=world
./hello.sh
echo $hello
source hello.sh
echo $hello
world