Sample Header Ad - 728x90

Find specific apps by name, getting their version, via command line

3 votes
3 answers
2115 views
For a support information gathering tool, I like to be able to look up several apps by name (or rather by their bundle ID) and fetch their versions. I don't like to use the find command for this as that's not going to find all possible apps, or it'll take forever. There's lsregister -dump, which knows about all those apps that interest me, but that command seems to offer no option to look up information only about specific apps. I'd have to filter the result with grep, but can't figure out how to filter it so that I can look for an app's bundle ID but also get the version (which appears in a different line). There's also mdfind, which might be suitable for my purpose. Let's, for instance, say I want to know about all installed "Word" apps, such as the 2008, 2011 and 365 versions. With lsregister -dump | grep 'com\.microsoft\.Word', I'd get these lines: identifier: com.microsoft.Word (0x800460c2) activityTypes: NOTIFICATION#:com.microsoft.Word, pv-e851f8544284d1 That's not helpful to inquire the version, is it? With mdfind "kMDItemCFBundleIdentifier == com.microsoft.Word" I'd get the paths: /Applications/Microsoft Office 2008/Microsoft Word.app /Applications/Microsoft Office 2011/Microsoft Word.app But how would I get the version from that? I thought I'd filter the resulting paths with xargs but that doesn't work with the spaces in the paths.
Asked by Thomas Tempelmann (1972 rep)
Nov 14, 2016, 03:22 PM
Last activity: Dec 29, 2022, 02:04 AM