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)

source

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)
+ }

Revision #1
Created 2020-06-21 11:08:45 UTC by Dustin Sweigart
Updated 2020-10-28 14:13:21 UTC by Dustin Sweigart