获取第一行内容
内容如下
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: GenuineIntel
Model name: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
CPU family: 6
Model: 140
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Stepping: 1
CPU(s) scaling MHz: 59%
CPU max MHz: 4200.0000
CPU min MHz: 400.0000
BogoMIPS: 4838.40
想获取第一行cpu架构,命令如下
$ lscpu|awk 'NR==1{print $0}'
Architecture: x86_64
NR是用来匹配第几行内容,NR==1表示第一行,print \$0是把整行输出。默认awk是空格分隔,所以如果是print \$1,就输出Architecture,如果是\$2就输出x86_64,如下
$ lscpu|awk 'NR==1{print $2}'
x86_64
标签:x86,64,print,awk,NR,CPU
From: https://www.cnblogs.com/studywithallofyou/p/17036829.html