57

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.

5 Answers 5

65

There are many ways, but try uname -a.

3
  • 22
    uname -p gives just the processor architecture. man uname for other options. Jun 3, 2010 at 16:55
  • 6
    @DougHarris I get x86_64 with -a but i386 with -p
    – GP89
    Jan 29, 2015 at 14:45
  • @GP89 Have the same condition with you.
    – 廖茂生
    Sep 28, 2020 at 7:53
19

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
18

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

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

You can use sysctl to get information about your CPU:

$ sysctl machdep.cpu.brand_string
machdep.cpu.brand_string: Apple M1 Pro

Now you can take this string and search in the internet to get details about this CPU brand.

If you want more information about the CPU you can use this command:

$ sysctl machdep.cpu
machdep.cpu.cores_per_package: 10
machdep.cpu.core_count: 10
machdep.cpu.logical_per_package: 10
machdep.cpu.thread_count: 10
machdep.cpu.brand_string: Apple M1 Pro
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTSE64 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 AES SEGLIM64
machdep.cpu.feature_bits: 151121000215084031
machdep.cpu.family: 6
0

Another method nobody mentioned is:

$ machine
arm64e
MACHINE(1)                                                               General Commands Manual                                                               MACHINE(1)

NAME
     machine – print machine type

SYNOPSIS
     machine

DESCRIPTION
     The machine command displays the machine type.

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.