Created
March 17, 2018 20:11
-
-
Save rafaelbeckel/39adee6f92aa1a07d686855ac7b322e9 to your computer and use it in GitHub Desktop.
Bash Script - Read variable from .env file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read_var() { | |
VAR=$(grep $1 $2 | xargs) | |
IFS="=" read -ra VAR <<< "$VAR" | |
echo ${VAR[1]} | |
} | |
MY_VAR=$(read_var MY_VAR .env) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It just works. Thank you!