在给定匹配后是否有搜索字符串的方法?
如果我运行dmidecode,它就会提供很多信息。例如:
BIOS Information
Vendor: ABCD
Version: 123456(V1.01)
Release Date: 01/01/1970
Address: 0xE0000
Runtime Size: 128 kB
ROM Size: 8192 kB
Characteristics:
PCI is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
BIOS ROM is socketed
EDD is supported
Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)
Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
5.25"/360 kB floppy services are supported (int 13h)
5.25"/1.2 MB floppy services are supported (int 13h)
3.5"/720 kB floppy services are supported (int 13h)
3.5"/2.88 MB floppy services are supported (int 13h)
8042 keyboard services are supported (int 9h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported
Targeted content distribution is supported
UEFI is supported
BIOS Revision: 1.21
Firmware Revision: 1.21现在,如果我是grep "version“,那么它将从dmidecode输出中获取各种匹配。相反,有没有办法在^BIOS字之后搜索行“版本”并在第一次匹配时停止?所以输出就像:
Version: 123456(V1.01)发布于 2020-09-01 14:16:49
在许多情况下,您可以在第一次匹配之后使用grep -A输出一些行,然后再重新执行该结果。
dmidecode | grep -A 3 "BIOS Information" | grep "Version"https://unix.stackexchange.com/questions/607354
复制相似问题