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
ex -sc '%!awk "\
\$1 == \"RABBITMQ_HOST\" && \$2 = \"rabbitmq1\"\
\$1 == \"RABBITMQ_PASS\" && \$2 = 12345\
" FS== OFS==' -cx file
POSIX Sed does not support the -i option. However ex can edit files
in place
Awk is a better tool for this, as the data is separated into records and fields
In either case Sed or Awk, you can utilize a newline or ; to do everything
in one invocation
You have double quoted strings with no variables inside, might as well use single quotes
You quoted your file name when it has no characters that need escaping
You have several unquoted uses of variables, almost never a good idea