I need to compare a domain key (string) of two different Info.plist files.
That is if keys are equal than statement A else statement B.
Something like this:
if defaults read "domainA" "key" == defaults read "domainB" "key" ; then
statement A
else
statement A
fi
How to get this?
Thanks, L.
giskard22
03-22-2006, 02:38 PM
You can enclose a statement in ` characters if you want the shell to run it and use the result. For example: echo `whoami` returns your username, whereas echo whoami returns "whoami".
hayne
03-22-2006, 02:42 PM
I suspect that you need a tutorial on shell scripting - see the last section of this Unix FAQ (http://forums.macosxhints.com/showthread.php?t=40648)
leonida
03-22-2006, 03:07 PM
Thanks for your clues and this how-to (http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-6.html#ss6.1). I've solved in this way:
T1=`defaults read "domainA" "key"`
T2=`defaults read "domainB" "key"`
if [ "$T1" = "$T2" ]; then
echo expression evaluated as true
else
echo expression evaluated as false
fi