I am trying to remove the value or replace the value in .env file using bash script
in my .env file I have
TEST_VAR=testVariable
I have inserted this TEST_VAR using bash script using the below script
#!/bin/bash
echo TEST_VAR="testVariable" >> .env
The problem is if I run the bash script again it will enter TEST_VAR multiple times in .env. How can I replace the value or may be remove this key pair value.
for example
If I run again the bash script with changed value
#!/bin/bash
echo TEST_VAR="updateValue" >> .env
it should show in .env file
TEST_VAR=updatedValue
rather than below
TEST_VAR=testVariable TEST_VAR=updatedValue