我想grep主板序列号和电脑的产品型号。我用了
sudo lshw | grep -m1 serial:
Run Code Online (Sandbox Code Playgroud)
grep 序列号(因为有多次出现“serial:”,我想要的是第一个。我怎样才能做到这一点并同时对“product:”进行 grep?还有多次出现的产品,第一个又是我想要的。
lshw 返回这个:
user@ubuntu:~$ sudo lshw
ubuntu-pc
description: Notebook
product: 23252DG (LENOVO_MT_2325)
vendor: LENOVO
version: ThinkPad X230
serial: R9TWZVR
width: 64 bits
capabilities: smbios-2.7 dmi-2.7 vsyscall32
configuration: administrator_password=disabled chassis=notebook family=ThinkPad X230 power-on_password=disabled sku=LENOVO_MT_2325 uuid=01ECC0B1-8251-CB11-8538-B7D9EC435D9B
*-core
description: Motherboard
product: 23252DG
vendor: LENOVO
physical id: 0
version: Not Defined
serial: 1ZPAB2AC2C1
slot: Not Available
*-cpu
description: CPU
product: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
vendor: Intel Corp.
physical id: 1
bus info: cpu@0 …Run Code Online (Sandbox Code Playgroud)