29

I'm writing a shell script, and I need to know the architecture, i.e. PPC or Intel. Back in the day, there was a program /bin/arch that told you, but my Mac doesn't seem to have it.

Is there an easy way I can do this? Grep for something in a logfile? Call some other program that spits that out as a side effect?

It would be nice to know what OS version I'm running too, but that may not be necessary.

35

There are many ways, but try uname -a.

3
  • 17
    uname -p gives just the processor architecture. man uname for other options. – Doug Harris Jun 3 '10 at 16:55
  • 5
    @DougHarris I get x86_64 with -a but i386 with -p – GP89 Jan 29 '15 at 14:45
  • @GP89 Have the same condition with you. – 廖茂生 Sep 28 '20 at 7:53
16

arch is available in /usr/bin/arch

You can get OS version information with sw_vers

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.6.3
BuildVersion:   10D573
$ sw_vers -productVersion
10.6.3
11

uname -m seems to output the same information as /bin/arch.

4
  • 8
    Not with me. arch outputs i368 and uname -m outputs x84_86. I run OSX on a 64bit machine. – Erik Aigner Dec 18 '12 at 19:35
  • @ErikAigner: Typo, perhaps? Shouldn't it be x86_64? – Dennis Williamson Dec 19 '12 at 6:02
  • Of course arch should return x86_64, that's why it's so strange. But I don't know why. – Erik Aigner Dec 19 '12 at 7:31
  • 1
    Same here: $ uname -m x86_64 $ arch i386 – Davi Lima Jan 21 '15 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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