I am trying to find a value within a properties file and declare it into a variable. Script below. I want the "memSize" to be the branch from the properties file. Right now it always tells me "Not found" What am I doing wrong?
It's kinda weird that your properties file looks like that, I think the key and value should be reversed...but it's ok, so the expected output is "ORD", right?
Try this:
Thanks for respones. I changed it to below. I now get an output of blank line followed by "TEST". So my memSize variable apparently gets modified but never displays. Am I doing something still wrong here?
I finally got it working. My problem? I apparently saved/or ftp'ed the .properties in a non ascii format. grrrrrrrr.
thanks for responses tho
---------- Post updated at 01:22 PM ---------- Previous update was at 12:35 PM ----------
Hi, sorry one more question.
If my properties file contained a line like
IAH,ATL,FRA,ODA = 128
And I read in this line and wanted to know if ATL=128 how would this look like? I have experimented with a couple things and keep messing it up. Oh and this line listed above can change so its not fixed with 4 values.
thanks again
The extra spaces you put everywhere in your config files make this a lot harder. It's also hard having to write this in bare-bones sh. In BASH or KSH I could split the list into an array, in sh the straightforward way is to grep it...
# Read IAH,ATL,FRA,ODA = 128 from a file
IFS="=" read VARS VALUE < file
# Delete extra spaces from $VARS
VARS=`echo "$VARS" | tr -d ' '`
# Check if ATL is in the string, making sure it's not just part of a var name
if echo "$VARS" | egrep -q "(^|,)ATL($|,)" &&
[ "$VALUE" -eq 128 ]
then
echo "ATL = 128"
fi