My shell script looks like this:
FAILED_REQUEST_DIRECTORY=/bla/bla2 \
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1234 \
-jar /xyz/abc-service-1.0-SNAPSHOT.jar \
--server.port=1111 \
--server.address=127.0.0.1 \
--kafka.bootstrap.servers=10.111.11.11:3197,10.112.12.111:3197,10.123.44.25:3197 \
--topic.pushcrew.encryptionKey=abc-def-egh \
--spring.application.name=name-sevice \
--fb.verification.token=token \
--management.trace.include.payload=true \
--topic.pushcrew.hits=activity-logs \
--max.block.ms=1000 \
--pager.duty.api.key=apikey \
--dsn=dsn
If I have to replace values of keys in the command, for ex: replacing value of key --server.address
with the value to shell script through a variable, how would I do it?
I understand it would look like following if I had to replace value for key --server.address:
sed -i "s#--server.address=.* #$SERVER_ADDRESS#g;
But how do I maintain the space that has to be there after the replacement and how do I make sure that part int the key only after =
(equals to) and before (space) gets replaced.