Export Variables From a File
If you store environment variables in a file and want to quickly export all of them it is actually not as simple as running an export
on each line.
# source $MY_FILE
# export $(cut -d= -f1 $MY_FILE)
Another thing you can do is update ~/.bashrc
or equivalent files for other shells and add a method to do this for you since those commands aren't easy to remember.
# ~/.bashrc
+ # exports variables stored in a file
+ function export_file() {
+ source $1
+ export $(cut -d= -f1 $1)
+ }
No Comments