Skip to content

Instantly share code, notes, and snippets.

@dehidehidehi
Last active August 23, 2022 23:11
Show Gist options
  • Save dehidehidehi/6c92f618e4d841e6cc8b2dce8a3b0b7d to your computer and use it in GitHub Desktop.
Save dehidehidehi/6c92f618e4d841e6cc8b2dce8a3b0b7d to your computer and use it in GitHub Desktop.
Python patch-env bash script which cleans .env files from comments and blank lines and allows multiple .env files to be passed as arguments
#!/bin/bash
# Documentation here :
# https://gist.github.com/dehidehidehi/6c92f618e4d841e6cc8b2dce8a3b0b7d
# Here's a bash script which would allow to easily concatenate the contents of multiple .env files.
# Just save this script and pass the .env file path (relative or absolute) as arguments.
ENV_VARS_LIST=""
for envFile in $@
do
grep -Ev '(#|^$)' $envFile
done
# Credits:
# The base idea for this script is credited to
# https://github.com/sterwill
# Grep idea is credited to
# https://github.com/mousomer
@dehidehidehi
Copy link
Author

Examples usage:
patchEnvProvider.sh envfile1.sh envfile2.sh envfile3.sh

Here's a bash script which would allow to easily concatenate the contents of multiple .env files.
Just save this script and pass the .env file path (relative or absolute) as arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment