shell script replace variables in file - error with Sed's -i option for in-place updating
Here is my test.env RABBITMQ_HOST=127.0.0.1 RABBITMQ_PASS=1234 And I want to use test.sh to replace the value in test.env to : RABBITMQ_HOST=rabbitmq1 RABBITMQ_PASS=12345 here is my test.sh #!/bin/bash echo "hello world" RABBITMQ_HOST=rabbitmq1 RABBITMQ_PASS=12345 Deploy_path="./config/test.env" sed -i 's/RABBITMQ_HOST=.*/RABBITMQ_HOST='$RABBITMQ_HOST'/' $Deploy_path sed -i 's/RABBITMQ_PASS=.*/RABBITMQ_PASS='$RABBITMQ_HOST'/' $Deploy_path But I have error sed: 1: "./config/test.env": invalid command code . sed: 1: "./config/test.env": invalid command code . How can I fix it? tl;dr : With BSD