grep "^\[bugID[[:digit:]]\{1,\}\]"
是第一行。我如何grep
bugID
或 TICKET-
[bugID12345] fix for performance issue
[TICKET-12345] fix for memory leak issue
[bugID23244] fix for performance issue
[TICKET-54678] fix for memory leak issue
答案 0 :(得分:1)
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]