#!/bin/bash # TODO: # Follow symlinks # No filename specified? if [ "$1" == "" ]; then echo "ERROR: Specify the file to read from."; exit 1 fi # Does the file exist? if [ ! -f $1 ]; then echo "ERROR: File not found"; exit 1 fi # Got ASCII? if ! [[ "`file -b $1`" =~ ^ASCII\ text* ]]; then echo "ERROR: File is not ASCII text."; exit 1 fi # Finally.. Let's get started. CS="" CSO=`date +%s` # Second Counter SC=0 tail -n0 -f $1 | while read line; do # Get current timestamp CS=`date +%s` # CS != CSO, show stats if [ "$CS" != "$CSO" ]; then LS=$((CS-CSO)) echo "LOOPING! - Count: $SC - Last loop second was $LS seconds ago" SC=0 CSO=$CS else SC=$(( SC + 1 )) fi done