Saturday, December 15, 2012

grepping the smart way

Unfortunately WebLogic prints each log entry in multiple lines. This is a pain when you grep.

gawk will return the whole log entry:

gawk "BEGIN{RS=\"####\"}/BEA-000337/{print \$0}" *.log


When using grep, the option -A4 is handy to print a few extra lines (in the example, 4) after the ling matching the pattern:

grep -A4 BEA-000337 *





No comments: