sysctl -n hw.ncpu
returns:
24
alias nproc='sysctl -n hw.ncpu' nproc
sysctl -a | egrep -i 'hw.ncpu'
or with some extra info:
sysctl -a | egrep -i 'hw.machine|hw.model|hw.ncpu'