#!/bin/sh - # timegrep - grep lines with a Unix time tab column within the given date range # Steve Kinzler, kinzler@cs.indiana.edu, Jan 03 # http://www.cs.indiana.edu/~kinzler/home.html#unix case "$1" in -h) set x; shift;; esac case "$#" in 1) set x "$@" zero now; shift;; 2) set x "$@" now; shift;; 3) ;; *) cat <&2 usage: $0 column [ start_date | zero | now ] [ end_date | now ] The column is numbered from one, or is NF to indicate the last column. By default, the start date is "zero", ie the beginning of the Unix epoch (1970 Jan 1), and the end date is "now". EOF exit 1;; esac col="$1"; shift now=`date` case "$1" in zero) start=0;; now) start=`getdate "$now"`;; *) start=`getdate "$1"`;; esac case "$2" in now) end=`getdate "$now"`;; *) end=`getdate "$2"`;; esac #echo "$0: grepping $start <= column $col <= $end" 1>&2 exec awk -F' ' "\$$col >= $start && \$$col <= $end"