I have set some variables in my shell, because I need them all the time. How can I make a script, that I call on the same shell that has variables set access the variables that are defined in the shell, without passing them explicitely as parameters?
1 Answer
You simply source the script with the assignments in your shell script like so:
. /path/to/settings # Dot, blank, name of file.
This will execute the contents of settings in the current shell (as opposed to starting a subshell, where assignments are lost after the subshell ends.)
2 Comments
flolo
You can also use the verbose form of the ".": "source".
source /path/to/settings/ will also work.user857990
sweet i didn't know it went this way as well