82

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 log file? 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.

Ricardo
  • 195
Brian Postow
  • 1,715

5 Answers5

93

There are many ways, but try uname -a.

churnd
  • 5,146
30

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

23

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
Doug Harris
  • 28,397
10

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
6

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.

deed02392
  • 3,132
  • 6
  • 30
  • 36