Friday, 12 January 2024

How to print out log entries that have more than two lines?

to print out the entries in server.log:

 gawk -v RS= '(gsub(/\n/, "&") > 2) { print; printf "\n" }' server.log

 

to print out the entries in all files (oldest first, newest last):

ls -tr | while read p; do cat $p; done | gawk -v RS= '(gsub(/\n/, "&") > 2) { print; printf "\n" }'

No comments:

Post a Comment

Note: only a member of this blog may post a comment.