Recently, one of my colleagues asked me some hints on how to read updated properties from one property file, search the same property in the target property file (files) and update/replace the corresponding property value (s) in the target property file (s) if property key matches. He wanted to do this operation using just the regular shell script, so No ANT or Java or Perl. I've put together a simple script file for him and decided to publish it here so that other people with similar needs can be benefited as I did not find any other similar posting.
Let's say, here is how the source property file looks like:
--------- sFile.properties --------
Let's say, here is how one of the target property files looks like:
--------- tFile.properties --------
Here is how the shell script file look like:
---------- propertyUpdater.sh ------
--------- tFile.properties after the update -----
Hope, it helps!
Let's say, here is how the source property file looks like:
--------- sFile.properties --------
# Updated property values |
Let's say, here is how one of the target property files looks like:
--------- tFile.properties --------
# Connection properties |
Here is how the shell script file look like:
---------- propertyUpdater.sh ------
#!/bin/bash |
--------- tFile.properties after the update -----
# Connection properties |
Hope, it helps!
Awesome blog, I enjoyed reading your articles. This is truly a great read for me.
ReplyDeleteDevOps Training
DevOps Online Training