Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

read env file bash

env=$(cat server/.env)

my_array=($(echo $env | tr " " "
"))

for i in "${my_array[@]}"
do
    my_nested_array=($(echo $i | tr "=" "
"))
    for j in "${my_nested_array[@]}"
    do
        echo $j
    done
done

# output:
# MY_ENV_VAR
# myenvvalue
# source: https://linuxhandbook.com/bash-split-string/
 
PREVIOUS NEXT
Tagged: #read #env #file #bash
ADD COMMENT
Topic
Name
5+4 =