0

I have an environment variable called ABCD in .ENV File. And Along with this, I have another env variable which is XYZ.

Let's assume this is my example.env file

ABCD=some_imp_value_which_is_variable
.
.
.
XYZ=testvalue.<value of ABCD>.xxxxx
.
.

In bash, If I want to read the value of ABCD, I would use $ABCD and store it to XYZ using XYZ=testvalue.$ABCD.xxxxx

ABCD=some_imp_value_which_is_variable
.
.
.
XYZ=testvalue.$ABCD.xxxxx

Do we have something similar to do in .env file. ABCD is variable value and we want XYZ to have the value based on ABCD.

We are avoiding script (as that will require lots of changes to be done), So instead we want to do it in .env file itself

IMSoP
  • 89,526
  • 13
  • 117
  • 169
axel
  • 21
  • 7
  • 1
    A `.env` file by itself is just a text file, and has no behaviour, so the answer to this is going to depend on what you're using to _read_ that file. – IMSoP Feb 28 '22 at 13:11
  • We are using docker container to read the file. This is technically ENV vars for a specific container. But this ENV file comes from somewhere else. The value of XYZ is empty in beginning, and we can only pass value to it. – axel Feb 28 '22 at 13:15
  • My opinion is .env files should always be handcrafted. Copy the contents as you need them and deploy the file on your desired system. – Daniel W. Feb 28 '22 at 14:09
  • Plain `docker run --env-file` can't do this; it does no interpretation on the contents of the file. Language-specific packages that read a `key=value` format file often can but it's not totally generic. – David Maze Feb 28 '22 at 14:21
  • Thanks everyone, As I was unable to change anything to that env file, I end up reading whole Env file being received and creating another file based on it using script and then sending it to docker container. – axel Feb 28 '22 at 15:19

0 Answers0