number of apps ext attrib

Valued Contributor II

Anyone have a way to run an extension attribute that returns # of applications installed?

The info is available under details in inventory lookup. It would be helpful for me if this was a searchable inventory field.

Thanks in advance.


Honored Contributor

Are you interested in all apps everywhere or just in particular places?

Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420

Valued Contributor

If you want anything from Applications (and all subfolders), then

find /Applications/ -name "*.app" | wc -l,

but is pretty slow.

If you want all and you have configured the OS to 'locate' files, then you could do

locate *.app | grep ".app$" | wc -l

If you just want apps on the system disk:

locate *.app | grep ".app$" | grep -v "^/Volumes" | wc -l

You could then further limit your hits by removing applications in the /Systems directory

locate *.app | grep ".app$" | egrep -v "^/Volumes|^/System" | wc -l

Just keep piping in the egrep to remove more lines, for example to get rid of all the lines starting /Library as well

locate *.app | grep ".app$" | egrep -v "^/Volumes|^/System|^/Library" | wc -l

Hopefully you get the idea.

As for having a searchable list, you already have one in the JSS. Advanced search > Criteria > Software Information

If you really feel for some reason that you want all of the Applications that are in /Applications listed in an EA, then you can run

ls -1 /Applications

Note, that is a number 'one' not a lower case letter L!


Contributor III

If you want to see all things that are called *.app in useful places like
/Applications use find etc. But if for example you want to count everything
in System Profiler this will work.

awk '/:$/ { n = NR } END { print n-1 }' < <(system_profiler

This just looks for all lines ending with a semicolon in the output
from system_profiler
SPApplicationsDataType and counts them up and then subtracts 1 for the top
where it will say "Applications:"

There are lots of ways to skin this cat based on exactly what you want.

Ryan M. Manly
Glenbrook High Schools

Contributor II

Has anyone come up with a solution that reflects one-to-one what shows in Jamf Inventory? I talked with Jamf Support and they gave me the following:

echo "<result>ls -l /Applications/* | grep .app | grep -v "->" | wc -l</result>"

(I actually added the grep -v "->" because the results included a shortcut to Silverlight, adding the fake error filtered out that).

It does provide an app count that includes all the .apps in the /Applications folder as well as one folder deeper (i.e. /Applications/EndNoteX8/), but I found that Jamf Inventory finds a few items in folders even deeper than that (i.e. /Applications/EndNoteX8/Services/). If I change the above command too ls -l /Applications//, then it finds more than Jamf. So for one computer:

Jamf Inventory: 114 Applications

ls -l /Applications/* | grep .app | grep -v "->" | wc –l

: 106 Applications

ls -l /Applications/*/* | grep .app | grep -v "->" | wc –l

: 121 Applications

Was just wondering if anyone had cracked getting a one-to-one extension attribute to match what's in Jamf Inventory.

Legendary Contributor II

@el2493 Does the Mac you're running this on have Xcode installed? I found that there are embedded apps inside the path, like /Applications/ and /Applications/ and several others. These end up throwing off the totals since it looks like Jamf Pro doesn't consider these applications in it's results. From what I can tell it only looks in /Applications/ and plus one additional level deep, which includes /Applications/Utilities/ It doesn't appear to search any deeper than that.

I was able to match my own machine's results in Jamf Pro (108 installed apps) with the following 2 versions of code. First one is much shorter, but might take slightly longer to run than the mdfind one believe it or not.

find /Applications -maxdepth 2 -name *.app | awk -F'/' '{print $NF}' | sort -f

Alternately using mdfind:

mdfind -onlyin /Applications/ 'kMDItemKind == "Application"' | egrep -v "/Contents/Applications/|/Contents/Developer/" | awk -F'/' '{print $NF}' | sort -f

The egrep stuff there is necessary because unlike find, mdfind doesn't have a level limiting function, so it will drill down as many levels as it can go to find stuff.

To get the total, throw a wc -l or awk 'END{print NR}' at the end of either one.

Contributor II

Thanks @mm2270 , mdfind was the closest I've come to getting an exact match. Jamf Inventory shows 114 apps, mdfind shows 113 (and if I compare the 2 lists of apps, they're identical except for 1 missing app). The one app it's missing (that Jamf finds) is called, and I'm having a hard time finding where it's actually stored on the computer. It's part of the EndNote application, but a Finder search doesn't come up with anything and I've tried manually looking through the the /Applications/Endnote X8 folder as well as for EndNote and am not having any luck. I also tried searching ~/Library folder and didn't find anything.

Since this is a component of EndNote (and mdfind detects both EndNote and, which are also components of EndNote) I at least know that the app is installed and can assume this one missing .app is also installed. I think this this is probably the best I'm going to get, so thanks again!

The find command finds 111 items, so decent but not as close as mdfind.