#!/bin/sh
# Copyright (c) 2011 Arista Networks, Inc.  All rights reserved.
# Arista Networks, Inc. Confidential and Proprietary.

# Takes a regex as command line argument, which will be used to filter log messages on stdin
# Matching lines are printed to stdout, as well as, if present, any succeeeding lines looking like 'message repeated N times'

awk '/Syslog logging:/,/Log Buffer:/ { print $0; next } # Print the logging configuration header as normal, if it exists
/message repeated .* times/ { if(x) print $0; next }
x = 0
/'$1'/ { x = 1; print $0 }'
