I have .env file that needs to updated dynamically with a shell script from the user input. SPRING_DATASOURCE_URL=jdbc:postgresql://192.168.1.55:30091/db_name I have a shell script
#/bin/bash
read -p "Please enter the Database IP:" DATABASE_IP
read -p "Please enter the Database Port:" PORT
echo $DATABASE_IP $PORT
sed -i "s/${DATABASE_IP}" ~/.env
I am not familiar with the string manipulation. How can I complete the shell script to update a .env file
sedcommands///substitutes one value by another one. I don't see a replacement value in your command.envsubst? Perhaps it is exactly what you need, and easier to use. The idea would be that you create a template environment file,.env_template, where you use a variable for the IP address jdbc:postgresql://$DATABASE_IP:30091/db_name, and then use envsubst to create from this the actual .env file.