set -o allexport
source conf-file
set +o allexport
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/