要修改的文件,kafka的server.properties
部署的配置config.ini
:修改脚本update.sh
#!/bin/bash
#导入文件
source ./config.ini
#根据正则表达式完成符串替换,sed -i 's/原字符串/替换字符串/g" 文件全路径名
sed -i "s/kafka_ip/${kafka_ip}/g" /home/kafka_2.11-0.11.0.0/config/server.properties
sed -i "s/kafka_port/${kafka_port}/g" /home/kafka_2.11-0.11.0.0/config/server.properties
~
执行 ./update.sh
执行结果