gpt4 book ai didi

linux - grep 交替搜索

转载 作者:太空宇宙 更新时间:2023-11-04 05:05:46 25 4
gpt4 key购买 nike

grep "^\[bugID[[:digit:]]\{1,\}\]" 用于第一行。我如何grep查找bugIDTICKET-

[bugID12345] fix for performance issue

[TICKET-12345] fix for memory leak issue

[bugID23244] fix for performance issue

[TICKET-54678] fix for memory leak issue

最佳答案

egrep 支持与 | 的交替,并且 [ 需要转义:

egrep "^\[(bugID|TICKET-)[[:digit:]]{1,}\]" file
[bugID12345] fix for performance issue
[TICKET-12345] fix for memory leak issue
[bugID23244] fix for performance issue
[TICKET-54678] fix for memory leak issue

如果您不需要整行,请使用 -o 选项:

egrep -o "^\[(bugID|TICKET-)[[:digit:]]{1,}\]" file
[bugID12345]
[TICKET-12345]
[bugID23244]
[TICKET-54678]

关于linux - grep 交替搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14069328/

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