A long time ago I wrote a little utility to timestamp input from
variable numbers of tty devices, iirc. I think I called it
timestamp-input. It prefixed the timestamp (in unix time) and source.
It was originally intended to interleave GPS data with instrument data
to facilitate geo-tagging the instrument data. Not sure I could lay my
hands on it again easily, but it was not terribly complex to write.

On Tue, Jul 27, 2021 at 1:45 PM Galen Seitz <gal...@seitzassoc.com> wrote:
>
> Hi,
>
> I was looking for a way to timestamp output from a serial port when I
> stumbled onto a tool that I'd never heard of.  The ts command, which is
> part of moreutils, will place a timestamp in front of each line of
> output from stdout.
>
> This:
> echo -e "foo\nbar\nbaz" | ts '[%Y-%m-%d %H:%M:%S]'
>
> yields something like this:
> [2021-07-27 13:37:36] foo
> [2021-07-27 13:37:36] bar
> [2021-07-27 13:37:36] baz
>
>
> Combined with picocom and tee, my logging command looks like this:
>
> picocom -b 9600 /dev/ttyUSB0 | ts '[%Y-%m-%d %H:%M:%S]' | tee
> "example_$(date +"%Y%m%d%H%M%S").log"
>
> moreutils contains about a dozen other commands which might come in
> handy at some point.
>
> <https://joeyh.name/code/moreutils/>
>
> galen
> --
> Galen Seitz
> gal...@seitzassoc.com

Reply via email to