首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在匹配后搜索字符串

在匹配后搜索字符串
EN

Unix & Linux用户
提问于 2020-09-01 12:04:12
回答 1查看 58关注 0票数 -2

在给定匹配后是否有搜索字符串的方法?

如果我运行dmidecode,它就会提供很多信息。例如:

代码语言:javascript
复制
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字之后搜索行“版本”并在第一次匹配时停止?所以输出就像:

代码语言:javascript
复制
Version: 123456(V1.01)
EN

回答 1

Unix & Linux用户

发布于 2020-09-01 14:16:49

在许多情况下,您可以在第一次匹配之后使用grep -A输出一些行,然后再重新执行该结果。

代码语言:javascript
复制
dmidecode | grep -A 3 "BIOS Information" | grep "Version"
票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/607354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档