Prefix each line with a timestamp
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Go to file
Klaus Alexander Seistrup dbac9e8ba2 Use explicit casts 2 months ago
contrib Update all copyright lines and remove year ranges 5 months ago
img Track img/identicon.png 11 months ago
src Use explicit casts 2 months ago
.gitignore Ignore backup files 8 years ago
AUTHORS.md Initial commit 8 years ago
INSTALL.md Version string are now kept in a separate version.h file 3 years ago
LICENSE Initial commit 8 years ago
README.md Version string are now kept in a separate version.h file 3 years ago
TODO.md s/Github/Codeberg 7 months ago

README.md

Timestamp

Prefix each line with a timestamp

timestamp prefixes each line received on standard input with a timestamp in the format YYYY-MM-DD HH:MM:SS.

Installation

Please see the included INSTALL.md file.

Usage

Usage: timestamp [OPTIONS] [FILENAME] [TEXT [TEXT …]]

positional arguments:
  FILENAME              optional output file
  TEXT                  optional startup message

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show version information and exit
  -c, --copyright       show copying policy and exit
  -u, --utc             use UTC rather than local time
  -r, --rfc3339         use RFC 3339 compliant timestamps
  -t, --tai64n          use TAI64n timestamps
  -f FORMAT, --format FORMAT
                        datetime format (default: %F %T)

Please see strftime(3) for possible conversion specifications.

Any TEXT after FILENAME will be stamped and written verbatim as
the first line before timestamp starts reading from standard
input. Use the pseudo filename - for standard output.

Example

$ (echo A; sleep 2s; echo B; sleep 3s; echo C) | timestamp
2020-11-20 10:29:44	A
2020-11-20 10:29:46	B
2020-11-20 10:29:49	C
$ (echo A; sleep 2s; echo B; sleep 3s; echo C) | timestamp --tai64n
@400000005fb78c9e339ac51c	A
@400000005fb78ca033d3fc29	B
@400000005fb78ca334742e9a	C

Stampit

stampit is a special flavour of timestamp that

  • uses RFC 3339 compliant timestamps with µs precision,
  • does not accept custom formats, but
  • accepts text to be stamped as argument(s), and
  • appends stamped lines to a file when the --output option is used.

This makes stampit a useful candidate for e.g.

  • posting to a twtxt.txt file, or
  • logging one-line events to an ever-growing logfile.

Usage

Usage: stampit [OPTIONS] [TEXT [TEXT …]]

positional arguments:
  TEXT                  optional text to timestamp

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show version information and exit
  -c, --copyright       show copying policy and exit
  -l, --localtime       use local time rather than UTC
  -o OUTPUT, --output OUTPUT
                        path of output file

If no TEXT is given on the command line, text is read
from standard input and stamped one line at a time.

RFC 3339 timestamps are given with µs precision.

Example

$ stampit Frække frølår
2017-04-06T16:49:21.727686+00:00        Frække frølår
$ stampit -o twtxt.txt Frække frølår
$ echo Crème brûlée | stampit -o twtxt.txt
$ cat twtxt.txt
2017-04-06T16:50:47.250455+00:00        Frække frølår
2017-04-06T16:51:02.068170+00:00        Crème brûlée

😄