Is there a way in a shell script to copy text into a local .env file so that I can automate setting those environment variables?
example, I want to copy this to an .env file that sits in the same directory I’m already cd’d to
PIN=1
DEVICE_PREFIX=xxx
DEV=true
>Solution :
#!/bin/bash
text=$(cat << EOF
PIN=1
DEVICE_PREFIX=xxx
DEV=true
EOF
)
# Specify the path to the .env file
env_file=".env"
# Copy the text to the .env file
echo "$text" > "$env_file"