中标认证

您所在的位置: 首页/ 认证测试/ 认证常见问题 认证常见问题

grep使用

2019-04-08

 grep -A [num] 表示打印以检查到的文本的后面的行数,例如grep出来的是VGA,

[root@12cnode1 pcie]# lspci -v |grep VGA -A 8
01:03.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] ES1000 (rev 02) (prog-if 00 [VGA controller])
        Subsystem: Hewlett-Packard Company Device 31fb
        Flags: bus master, stepping, medium devsel, latency 64, IRQ 23
        Memory at e8000000 (32-bit, prefetchable) [size=128M]
        I/O ports at 2000 [size=256]
        Memory at e0710000 (32-bit, non-prefetchable) [size=64K]
        [virtual] Expansion ROM at e0720000 [disabled] [size=128K]
        Capabilities: [50] Power Management version 2
        Kernel driver in use: radeon
 
grep -B [num]则是before的意思,即之前的文本,grep的为VGA
 
 
[root@12cnode1 pcie]# lspci -v |grep VGA -B 8
        I/O ports at 1090 [size=8]
        I/O ports at 1098 [size=4]
        I/O ports at 10a0 [size=16]
        I/O ports at 10b0 [size=16]
        Capabilities: [70] Power Management version 3
        Capabilities: [b0] PCI Advanced Features
        Kernel driver in use: ata_piix
 
01:03.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] ES1000 (rev 02) (prog-if 00 [VGA controller])