Hi Friends,
I have a requirement to parse a properties file having a key=value pairs.
i need to count the number of key value pairs in the properties file and iterate through each key-value pair. I have written the script to read the number of lines from the property file, but cannot iterate through the count since the total number of lines is in string. Can you please help me in completing the below script.
Kindly find the script below
#declaring the propertie file
. appl.properties
#expression to count the number of lines excluding the blank lines
lines= cat appl.properties | sed '/^\s*$/d' | wc -l
echo "Number of lines is $lines"
for ((i=0;i -le 4; i++ ));
do
echo "pradeep";
done
sample properties file
#key=value
firstname=Pradeep
lastname=kumar
country=India
language=English
Desired output from shell script:
It should read the number of line which is 4. And then iterate 4 times using for loop and then printing the name and the value for each key value.
-- please use code tags