#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# isis_show_truncate - Run a command and limit the number of lines output
#
# April 2024, Paul Wells
#
# Copyright (c) 2024 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

max_lines=1000

#
# Parse the command-line parameters.
#
if [ "$1" == "-n" ]; then
    shift
    max_lines=$1
    shift
fi

#
# Run the command.
#
$@ 2>&1 | awk -v N=$max_lines 'NR<=N; NR>N {print "\n*** output truncated ***"; exit}'

