Fred Bongers Fred Bongers - 4 months ago 32
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

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

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

and

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

Comments