I am needing to use app version in a .sh script on Mac osX 10.10 so that I can do a compare to another number so I can force an update or not.
So far I have this (I am using Firefox.app as an example)
FirefoxmdlsVersion= mdls -name kMDItemVersion /Applications/Firefox.app;
echo $FirefoxmdlsVersion
This returns kMDItemVersion = "34.0"
which is a step in the right direction but I need just the number so that I can do my compare example 340
Here is what I have attempted to do with a new variable but I dont get an error or output at all
FFV2=${FirefoxmdlsVersion//'kMDItemVersion ='}
FFV3=${FirefoxmdlsVersion:18:4}
I maybe going in the wrong direction here, but Ive looked a post and havent made any progress. Can anyone help me?
To add one more option to the list, you can also use the defaults
tool.
For example:
defaults read /Applications/Firefox.app/Contents/Info.plist CFBundleShortVersionString
Will output the value of the CFBundleShortVersionString
entry from Firefox's Info.plist file, e.g.: 74.0
I prefer to use the defaults
command because there are no preconditions to using it and the command is very simple.
If you have Xcode and the developer tools installed, you can always use PlistBuddy...
For example:
/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" /Applications/TextEdit.app/Contents/Info.plist
gives me back the version number of "1.10
" under Yosemite.
The Info.plist file of any app usually has a version under the "CFBundleShortVersionString
" key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With