How to capture only some part of output when command executed??

Hi,

When I execute this command
prtdiag -v

output sample :
System clock frequency: 160 MHZ
Memory size: 4GB

==================================== CPUs ====================================
E$ CPU CPU
CPU Freq Size Implementation Mask Status Location
--- -------- ---------- --------------------- ----- ------ --------
0 1280 MHz 1MB SUNW,UltraSPARC-IIIi 2.4 on-line MB/P0
1 1280 MHz 1MB SUNW,UltraSPARC-IIIi 2.4 on-line MB/P1

================================= IO Devices =================================
Bus Freq Slot + Name +
Type MHz Status Path Model
------ ---- ---------- ---------------------------- --------------------
pci 66 MB pci108e,1648 (network)
okay /pci@1f,700000/network@2

pci 66 MB pci108e,1648 (network)
okay /pci@1f,700000/network

But I want only CPU count i.e 0 and 1 from above output.
How can I parse the output for only CPU column in shell script?

use the "psrinfo" command...

are you looking for something like this ?

prtdiag -v | grep -A3 'CPU' # print three lines After the pattern matched.

but what if you have 4 cpus or 8 or 64?

Try:

prtdiag -v | awk '/^CPU/,/^=/ { if($0 ~ /^[0-9]+/) print; }' | wc -l

or

prtconf | grep -c cpu