# If 'include' variable is true, print subset of file with timestamp between # startSec and endSec. If 'include' variable is false, print subset of file # with timestamp NOT within startSec and endSec. # timeStamp is in first column # Presumes that file timestamps are sorted in increasing order. BEGIN { if (ARGC < 3) { print "usage: startSec endSec timestamp-file"; exit; } ### Set include=1 to INCLUDE only time-window data; set include=0 to ### EXCLUDE time-window data include = 0; startSec = ARGV[1]; ARGV[1] = ""; endSec = ARGV[2]; ARGV[2] = ""; if (endSec <= startSec) { printf "endSec must be greater than startSec\n"; exit; } } NF == 0 { next; } /^#/ { next; } { if (include) { if ($1 >= startSec && $1 < endSec) { print; } } else { if ($1 >= startSec && $1 < endSec) { next; } print; } if ($1 > endSec) { // All done exit; } } END { }