I am trying to update specific entries in a document from a user prompt in a shell script. The user should be promoted to enter their domain name and then the script should update the ‘yourdomain.com’ section on 3 different lines. The name of the text file is .env
IMAGE_REPO=tacticalrmm/
VERSION=latest
TRMM_USER=username
TRMM_PASS=password
APP_HOST=rmm.yourdomain.com
API_HOST=api.yourdomain.com
MESH_HOST=mesh.yourdomain.com
>Solution :
it is very easy, you can use sed to update specific entries in the .env file from a shell script
#!/bin/bash
read -p "Enter your domain name: " domain
sed -i "s/yourdomain.com/$domain/g" .env
echo "Updated values:"
cat .env
I’ve helped you this time, but remember that no one here is writing code for anyone, we’re here to solve your problems in your code and help you!