rajeshkumar created the topic: How to read a .properties file through script
The easy way to do it is to note that a Java properties file has the same format as a basic shell script.
However, there’s a trick to it. If you just run the properties file like so:
The assignments will be made at the sub-level, then discarded when the properties file (script) ends execution.
So to get the properties in a calling script, you need to use the “source” command:
Note that the space after the initial dot is very important!
To reference shell variable assignments, you use the “$” to indicate variable substitution.
So, to put it all together:
# # Sample shell script to read and act on properties
# # source the properties:
# . appl.properties
# # Then reference then:
# echo "My name is $name and I'm $age years old."
Twitt me @ twitter.com/RajeshKumarIn
- Sonarqube Errors and Database - July 21, 2020
- How to exclude specific host from inventory from a playbook run in Ansible? - July 16, 2020
- Top 30 Free grammar checker and spell checker tools in 2020 - July 15, 2020