How to apply on Debian 13 `ts` to both `std{out,err}`?
Sep 24, 2:23pm

On Debian 13, ts (from the moreutils package: apt install moreutils) only reads stdin, so how you wire it depends on what you want:

Merge both streams into one timestamped output (loses stream distinction):

bash
mycommand 2>&1 | ts

Timestamp both streams while keeping them separate — use process substitution:

bash
mycommand > >(ts) 2> >(ts)

This prefixes each line of stdout and stderr with its own timestamp, but they still go to the terminal's stdout and stderr respectively.

Keep stream separation but send both to the terminal the usual way:

bash
mycommand > >(ts) 2> >(ts >&2)

Here, timestamped stderr is redirected back to stderr (useful when piping further or inside scripts).

Notes:

  • 2>&1 | ts merges stderr into stdout before timestamping — order of interleaved lines may be buffered slightly differently than the original process produced them.
  • With process substitution, bash is required (it doesn't work in dash/sh). Debian's default interactive shell is bash, so it works out of the box.
  • Common use: mycommand > >(ts '%H:%M:%.S ') 2> >(ts '%H:%M:%.S ' >&2) for per-line timing.
Sep 24, 2:23pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more