enthuguy
asked on
best way to access property values in shell
hi,
Is it possible to access property values in below way in shell script ? :)
would like to dynamically get property value based on a property which has variable as part of it.
# prop.properties
COUNTRY_LIST=USA,AUS
USA_STATES=NY,NJ
AUS_STATES=NSW,TAS
# getStatus.sh
source prop.properties
for COUNTRY in $(echo ${COUNTRY_LIST} | sed "s/,/ /g")
do
echo "COUNTRY : $COUNTRY"
# Would like to get "NY,NJ" and "NSW,TAS" respectively
# Would like to get USA_STATES AND AUS_STATES
echo "COUNTRY_STATES : ${COUNTRY}_STATES"
done
Thanks in advance
Is it possible to access property values in below way in shell script ? :)
would like to dynamically get property value based on a property which has variable as part of it.
# prop.properties
COUNTRY_LIST=USA,AUS
USA_STATES=NY,NJ
AUS_STATES=NSW,TAS
# getStatus.sh
source prop.properties
for COUNTRY in $(echo ${COUNTRY_LIST} | sed "s/,/ /g")
do
echo "COUNTRY : $COUNTRY"
# Would like to get "NY,NJ" and "NSW,TAS" respectively
# Would like to get USA_STATES AND AUS_STATES
echo "COUNTRY_STATES : ${COUNTRY}_STATES"
done
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER