I have .env file and I am trying to parse the value from it.
I ran this
cat .env | grep PORT=
I got
PORT=3333
How do I grab the value of a specific key?
I have .env file and I am trying to parse the value from it.
I ran this
cat .env | grep PORT=
I got
PORT=3333
How do I grab the value of a specific key?
cat env | grep PORT= | cut -d '=' -f2
Let say your input looks like this :
$ cat test.txt
Port=2020
Email=me@myserver.com
Version=2.02
Then this will do :
awk -F'=' '/^Version/ { print $2}' test.txt
2.02
Use eval
to parse the assignment line, later variable values can be substituted with $
:
eval "$(grep ^PORT= .env)"
echo $PORT