gpt4 book ai didi

regex - 我可以在我想要的字符串之前或之后 grep 一定数量的行吗?

转载 作者:可可西里 更新时间:2023-11-01 11:48:14 27 4
gpt4 key购买 nike

<分区>

假设我正在使用 lshw 获取我的系统内存,并且我希望将其打印出来以便我只获取系统内存选项。你能在 grep 中指定要在字符串之前或之后打印多少行吗?下面输出了一段lshw命令供引用:

 description: Computer
width: 64 bits
*-core
description: Motherboard
physical id: 0
*-memory
description: System memory
physical id: 0
size: 23GiB
*-cpu
product: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
vendor: Intel Corp.
physical id: 1
bus info: cpu@0
capacity: 1896MHz
width: 64 bits

我可以使用 lshw | grep 大小 | awk -F: '{print $2}' 以获得 23 GiB 部分,但我想看看是否有办法使用 grep 获取文本 block 以获取完整的内存部分。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com