Fred Bongers Fred Bongers - 8 months ago 71
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?


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.