ets(1)

ETS(1) General Commands Manual ETS(1)

NAME

etscommand output timestamper

SYNOPSIS

ets [-s | -i] [-f format] [-u | -z timezone] [-d delimiter] command [arg ...]

ets [options] shell_command

ets [options]

DESCRIPTION

ets prefixes each line of a command's output with a timestamp. Lines are delimited by CR, LF, or CRLF.

The three forms in SYNOPSIS correspond to three command execution modes:

  • If given a single command without whitespace(s), or a command and its arguments, execute the command with exec in a pty;
  • If given a single command with whitespace(s), the command is treated as a shell command and executed as ‘SHELL -c shell_command’,where SHELL is the current user's login shell, or sh if login shell cannot be determined;
  • If given no command, output is read from stdin, and the user is responsible for piping in a command's output.

There are three mutually exclusive timestamp modes:

  • The default is absolute time mode, where timestamps from the wall clock are shown;
  • -s, --elapsed turns on elapsed time mode, where every timestamp is the time elapsed from the start of the command (using a monotonic clock);
  • -i, --incremental turns on incremental time mode, where every timestamp is the time elapsed since the last timestamp (using a monotonic clock).

The default format of the prefixed timestamps depends on the timestamp mode active. Users may supply a custom format string with the -f, --format option.

The timezone for absolute timestamps can be controlled via the -u, --utc and -z, --timezone options. Local time is used by default.

The full list of options:

-s, --elapsed
Run in elapsed time mode.
-i, --incremental
Run in incremental time mode.
-f, --format format
Use custom strftime(3)-style format string format for prefixed timestamps.

The default is “[%Y-%m-%d %H:%M:%S]” for absolute time mode and “[%H:%M:%S]” for elapsed and incremental time modes.

See FORMATTING DIRECTIVES for details.

-u, --utc
Use UTC for absolute timestamps instead of local time.

This option is mutually exclusive with --z, --timezone.

-z, --timezone timezone
Use timezone for absolute timestamps instead of local time. timezone is an IANA time zone name, e.g. “America/Los_Angeles”.

This option is mutually exclusive with -u, --utc.

-c, --color
Print timestamps in color.
-d, --delimit
Change the delimiter between the timestamp and the command output.

The default is space.

FORMATTING DIRECTIVES

Formatting directives largely match strftime(3)'s directives on FreeBSD and macOS, with the following differences:

  • Additional directives %f for microsecond and %L for millisecond are supported.
  • POSIX locale extensions %E* and %O* are not supported;
  • glibc extensions %-*, %_*, and %0* are not supported;
  • Directives %G, %g, and %+ are not supported.

Below is the full list of supported directives:

%A
is replaced by national representation of the full weekday name.
%a
is replaced by national representation of the abbreviated weekday name.
%B
is replaced by national representation of the full month name.
%b
is replaced by national representation of the abbreviated month name.
%C
is replaced by (year / 100) as decimal number; single digits are preceded by a zero.
%c
is replaced by national representation of time and date.
%D
is equivalent to “%m/%d/%y”.
%d
is replaced by the day of the month as a decimal number (01-31).
%e
is replaced by the day of the month as a decimal number (1-31); single digits are preceded by a blank.
%F
is equivalent to “%Y-%m-%d”.
%f
is replaced by the microsecond as a decimal number (000000-999999).
%H
is replaced by the hour (24-hour clock) as a decimal number (00-23).
%h
the same as %b.
%I
is replaced by the hour (12-hour clock) as a decimal number (01-12).
%j
is replaced by the day of the year as a decimal number (001-366).
%k
is replaced by the hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a blank.
%L
is replaced by the millisecond as a decimal number (000-999).
%l
is replaced by the hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a blank.
%M
is replaced by the minute as a decimal number (00-59).
%m
is replaced by the month as a decimal number (01-12).
%n
is replaced by a newline.
%p
is replaced by national representation of either "ante meridiem" (a.m.) or "post meridiem" (p.m.) as appropriate.
%R
is equivalent to “%H:%M”.
%r
is equivalent to “%I:%M:%S %p”.
%S
is replaced by the second as a decimal number (00-60).
%s
is replaced by the number of seconds since the Epoch, UTC (see mktime(3)).
%T
is equivalent to “%H:%M:%S”.
%t
is replaced by a tab.
%U
is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number (00-53).
%u
is replaced by the weekday (Monday as the first day of the week) as a decimal number (1-7).
%V
is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (01-53). If the week containing January 1 has four or more days in the new year, then it is week 1; otherwise it is the last week of the previous year, and the next week is week 1.
%v
is equivalent to “%e-%b-%Y”.
%W
is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (00-53).
%w
is replaced by the weekday (Sunday as the first day of the week) as a decimal number (0-6).
%X
is replaced by national representation of the time.
%x
is replaced by national representation of the date.
%Y
is replaced by the year with century as a decimal number.
%y
is replaced by the year without century as a decimal number (00-99).
%Z
is replaced by the time zone name.
%z
is replaced by the time zone offset from UTC; a leading plus sign stands for east of UTC, a minus sign for west of UTC, hours and minutes follow with two digits each and no delimiter between them (common form for RFC 822 date headers).
%%
is replaced by ‘%’.

SEE ALSO

ts(1), strftime(3)

HISTORY

The name ets comes from “enhanced ts”,referring to moreutils ts(1).

AUTHORS

Zhiming Wang <i@zhimingwang.org>
and Contributors

March 2, 2025