我想要一台电脑的主板序列号和产品型号。我用
sudo lshw | grep -m1 serial:对于grep,序列号(因为有多次出现的“串行:”),而我想要的是第一个。我如何做到这一点,同时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
version: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
serial: None发布于 2017-05-04 11:19:19
使用grep和-class选项:
sudo lshw -class system | grep 'product\|serial'https://unix.stackexchange.com/questions/363004
复制相似问题