Fred Bongers Fred Bongers - 1 year ago 124
Linux Question

Grep information from /proc/cpuinfo

I'm trying to grep the model from /proc/cpuinfo in Ubuntu with this command:

cat /proc/cpuinfo | grep 'model'

But i'm getting 2 lines as output:

model : 60
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz

I will get only this line as output:

model : 60

How can i do this?

Answer Source

You can use 'sed' to parse out individual lines.

cat /proc/cpuinfo | grep 'model' | sed -n "1p" will give you model: 60


cat /proc/cpuinfo | grep 'model' | sed -n "2p" will give you the second line as output.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download