Table of Contents


tscat - add a timestamp to each line of standard input


tscat [-a] [-r] [-d] [FILE] ...


Read lines from standard input or FILE(s), and write them to standard output with a timestamp prepended to each line.


-a, --absolute (default)
write timestamps as the current time of day, e.g. [17:28:24.082905].
-r, --relative
write timestamps as elapsed seconds since the start of the tscat process
-d, --delta
write timestamps as elapsed seconds since the previous line of output (i.e., the previous timestamp)


tscat is most useful as a pipe, processing the standard output of a relatively slow process for diagnostic purposes:

slowprogram | tscat

The original motivation for tscat was diagnosing slow SSH connections: ssh -v gives lots of information, but it’s hard to remember after-the-fact just which step was the slow one. The catch is that ssh writes its verbose output to standard error rather than standard output, so to use it with tscat requires a bit of shell trickery:

ssh -v ... 2>&1 | tscat

(requires a Bourne-style shell).


When run as a pipe, tscat is only useful if its standard input -- the standard output of the process being "watched" -- is line-buffered or unbuffered. Unfortunately, standard output typically becomes block-buffered when it is a pipe, thus defeating the utility of tscat. The moral of the story: if you are writing a program whose standard output might be slow, be sure to flush it regularly, or explictly force line buffering.


Greg Ward <gward-tscat at python dot net> or <greg-tscat at gerg dot ca>.


The latest version of tscat is always available from .

See Also


Table of Contents