Skip to content

Instantly share code, notes, and snippets.

@hjr265
Last active November 29, 2015 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjr265/9703857 to your computer and use it in GitHub Desktop.
Save hjr265/9703857 to your computer and use it in GitHub Desktop.
Reads each line from .env file in the current directory and exports key=value to environment
#!/bin/bash
name=${1:-.env}
while read -r line
do
line=`echo "$line" | sed -e 's/^ *//' -e 's/ *$//'`
if [[ X"" = X"$line" ]]
then
continue
fi
key=${line%%=*}
value=${line#*=}
export $key=$value
done < $name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment