So, that silly time-stamp logger thingie ended up becoming a bug in my brain that wouldn't rest until I made it into an actual useful script that could do both of the types of time-stamping mentioned so far. Plus, the "time since program start" idea made me realise yet a 3rd way to count that someone might want in some cases, "time-since-last-event". So here is an awk script that takes an optional command line arg "mode=s" or "mode=l" and can do any of above depending on mode=x if no mode=x specified, it's the same as mode=a , since I think thats the most commonly expected form of timestamping. In all cases it's very lightweight, no extra processes, and only awk (which is a lot lighter than say, perl. I reduced the number of digits in the days from 4 to 3, to eliminate the misleading appearance that it's the year in there. That still allows for 2.73 years of continuous operation. heh. Sample runs showing each mode: whoa:~ $ (echo this ;sleep 4 ;echo is ;sleep 3 ;echo a ;sleep 1 ;echo test) |tscat 20081121011128: this 20081121011132: is 20081121011135: a 20081121011136: test whoa:~ $ (echo this ;sleep 4 ;echo is ;sleep 3 ;echo a ;sleep 1 ;echo test) |tscat mode=s 000:00:00:00: this 000:00:00:04: is 000:00:00:07: a 000:00:00:08: test whoa:~ $ (echo this ;sleep 4 ;echo is ;sleep 3 ;echo a ;sleep 1 ;echo test) |tscat mode=l 000:00:00:00: this 000:00:00:04: is 000:00:00:03: a 000:00:00:01: test whoa:~ $ And the script: whoa:~ $ cat bin/tscat #!/usr/bin/awk -f # tscat - time-stamp cat # Use like "cat". # Copies stdin to stdout with a timestamp prepended to each line. # Options: # mode=a absolute system time (default) "yyyymmddhhmmss: input-text..." # mode=s elapsed since start "ddd:hh:mm:ss: input-text..." # mode=l elapsed since last line "ddd:hh:mm:ss: input-text..." # # myprogram |tscat (same as "myprogram |tscat mode=a") # myprogram |tscat mode=s # tscat =60) { m=s/60 ; s%=60 } if (m>=60) { h=m/60 ; m%=60 } if (h>=24) { d=h/24 ; h%=24 } printf ("%03i:%02i:%02i:%02i: %s\n",d,h,m,s,$0) } (mode=="l"){ S=systime() } whoa:~ $ -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org