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
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]