Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

For an approximate count — and to get an idea of the time taken to count — I began with a multi-line command that could run in tcsh.

I'm not a plumbing expert, so I invite answers that are better than the earliest one given by me below.


To keep the walk not excessively time-consuming, I'd like to:

  • walk just a few hierarchies that are most likely to contain binaries
  • not begin the walk at / root.

I'm as interested in the time taken to count, as the approximate count.


arch(3) Mac OS X Developer Tools Manual Page

lipo(1) Mac OS X Manual Page

share|improve this question
I had to 2>/dev/null before the pipe to prevent a ton of crap from being printed. –  Daniel Beck Jan 31 '12 at 9:48
Thanks Daniel. I edited my question to make clear that I manually count the number of lines of output (I don't know whether this can be plumbed). Did you use tcsh? –  Graham Perrin Jan 31 '12 at 9:49
Consider posting your approach as an answer, like I did e.g. here. –  Daniel Beck Jan 31 '12 at 9:50
I'm playing around with it right now, but no, I use bash. –  Daniel Beck Jan 31 '12 at 9:50
add comment

3 Answers

up vote 3 down vote accepted

I use the following in bash, keeping the overall approach (using lipo) the same:

time find ${PATH//:/ } /Applications /Developer /Library /System ~/Applications -type f -exec lipo -info '{}' ';' 2>/dev/null | grep -E "(x86_64|i.86|pent)" | tee binaries.txt | wc -l

It will create a file, binaries.txt with the list of results, and print the number of results, as well as the time results, to standard output.

I shortened the man 3 arch based grep expression, removed the i860 entry, and used $PATH instead of a hardcoded list of Unix binary locations. I also removed the -perm primary from find, as it's a heuristic that might miss binaries only executable for specific users.

share|improve this answer
To be honest, it's a whole lot faster with the -perm primary :-/ –  Daniel Beck Jan 31 '12 at 10:06
Seems I get a whole lot of false positives, if you don't want to find libraries, this way (it's still running :-) ). –  Daniel Beck Jan 31 '12 at 10:16
Without permissions filter: 9531. With permissions filter: 8394. It takes more than ten times as long without on my system though. –  Daniel Beck Jan 31 '12 at 10:18
Daniel, you're amazing. Thanks! It's certainly time-consuming, here more than twenty minutes for my earlier untidy approach to complete. –  Graham Perrin Jan 31 '12 at 10:26
add comment

In tcsh:

uname -v && date &&\
2>/dev/null find /opt/X11/bin /opt/local/bin /opt/local/sbin \
/bin /sbin /usr/X11/bin /usr/bin /usr/local/bin /usr/sbin \
/Applications /Developer /Library /System ~/Applications \
-type f -perm +111 -exec lipo -info '{}' ';' | grep -E \
"(i386|x86_64|i860|i486|i486SX|pentium|i586|pentpro|i686|pentIIm3|pentIIm5|pentium4)" &&\
date && exit

The number of lines of output can be counted in a text editor such as TextWrangler. Subtract from the beginning the few lines up to and including the date and time, subtract from the end the two lines that include the date and time, that leaves an approximate figure.

If you wonder why the grep is for any of twelve architectures (not two): it's to consider all currently known architectures where the description, in the man page for arch, includes Intel. Finding anything other than i386 or x86_64 may be rare or unknown at the moment, but I'd like the answers to this question to stand the test of time, to be not limited to those two.

As an answer, this is far from ideal …

share|improve this answer
i860? It has a different instruction set... –  Daniel Beck Jan 31 '12 at 10:23
Most architecture and instruction set stuff is way beyond me, to be honest. I recognise Pentium as something that sounds outdated. I have no idea whether anyone might try Darwin 11 on i860 … and so on. Parts of this answer are probably very far from ideal! –  Graham Perrin Jan 31 '12 at 11:09
Is lipo the best tool for this sort of thing? Inspiration for the lipo approach is given around http://www.wuala.com/grahamperrin/public/2011/07/12/ppc-lister. System Information.app is in many ways user-friendly, and will list applications quickly, but it doesn't provide detail of the type that we get from lipo. –  Graham Perrin Jan 31 '12 at 11:20
I'm not sure the Non-fat expression (on the linked page) is correct. Mac OS (classic) had fat binaries as well, working on both 68k and PPC. Not sure what the output there is though. –  Daniel Beck Jan 31 '12 at 11:36
add comment

A little beyond the opening question

Sill experimenting, here's a variation on the accepted answer from Daniel:

date && sw_vers && uname -a && touch /Users/Shared/binaries.log && bash 
open /Users/Shared/binaries.log && time find ${PATH//:/ } \
/Applications /Developer /Library /System ~/Applications \
-type f -exec lipo -info '{}' ';' 2>/dev/null \
| grep -E "(x86_64|i.86|pent)" | tee /Users/Shared/binaries.log \
| wc -l && exit

It uses a shared area to write the file, with a name ending in .log, and should open the .log in Console. Also the Terminal window will show the date and time, system version and build — things that I like to keep a note of.

It does not bring the log window to foreground if other windows of Console are open, and does not bring Terminal to foreground at completion.

On some systems the walk may be very time-consuming.

For a faster run

We can use the -perm primary of find — 

date && sw_vers && uname -a && touch /Users/Shared/binaries.log && bash 
open /Users/Shared/binaries.log && time find ${PATH//:/ } \
/Applications /Developer /Library /System ~/Applications \
-perm +111 -type f -exec lipo -info '{}' ';' 2>/dev/null \
| grep -E "(x86_64|i.86|pent)" | tee /Users/Shared/binaries.log \
| wc -l && exit

— but as Daniel commented, this might miss binaries that are only executable for specific users.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.