-1

I want to grab the cpu model of an android device using

cat /proc/cpuinfo

The output is something like this

Processor   : AArch64 Processor rev 3 (aarch64)
processor   : 0
processor   : 1
processor   : 2
processor   : 3
processor   : 4
processor   : 5
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 3

Hardware    : Qualcomm Technologies, Inc msm8992
Revision    : 000b

Now what I need is only the "msm8992". The last 4 numbers change from devices to another, So what I was thinking is to search for word that starts with "msm" and extract it but I am struggling with grep / awk commands.

Omar
  • 81
  • 1
  • 7
  • Please show the relevant code. Also see [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – jww Dec 08 '18 at 06:02

2 Answers2

2

perhaps search for "Hardware" and extract the last word

$ awk '/^Hardware/{print $NF}' /proc/cpuinfo

grep -oE 'msm[0-9]+' might do as well.

karakfa
  • 66,216
  • 7
  • 41
  • 56
-1

since you tag awk, I used awk for It. Please check it out

grep msm /proc/cpuinfo | awk '{print substr($0, length($0)-6,7)}'
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72