Shell Script for Reading the properties file of Java type

by Balasundaram

sed ‘/^\#/d’ property_file_name | grep ‘property_name’ | tail -n 1 | cut -d “=” -f2- | sed ‘s/^[[:space:]]*//;s/[[:space:]]*$//’

This command gives the property value from the properties file .

# gres.sh
pattern=$1
replacement=$2
propvalue=`sed ‘/^\#/d’ $3 | grep $1 | tail -n 1 | sed ‘s/^.*=//;s/^[[:space:]]*//;s/[[:space:]]*$//’`
A=”`echo | tr ’12’ ’01’ `”
sed -i -e “s$A$pattern=$propvalue$A$pattern=$replacement$A” $3
# end script

This replaces a property value within a given property file:

./gres.sh

Advertisements