-1

grep "^\[bugID[[:digit:]]\{1,\}\]"是第一行。我该怎么grepbugID 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
4

1 回答 1

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]
于 2012-12-28T12:25:25.423 回答