News for hackers. Stuff that matters.
Re:The Hidden Gems of Moreutils by atomicstack on Saturday December 30, 2023 @10:26AM (#38815940)
I use `ts` quite often in adhoc logging/monitoring contexts. Because it uses strftime() under the hood, it has automatic support for '%F' and '%T', which are much easier to type than '%Y-%m-%d' and '%H:%M:%S'. Plus, it also has support for high-resolution times via '%.T', '%.s', and '%.S':

  echo 'hello world' | ts '[%F %.T]'
  [2023-12-30 16:25:40.463640] hello world
Re:The Hidden Gems of Moreutils by c0l0 on Saturday December 30, 2023 @01:33PM (#38817524)
Assuming semi-recent bash(1), you can also get away with something like

    while read -r line; do printf '%(%F %T %s)T %s\n' "-1" "${line}"; done
as the right-hand side/reader of a shell pipe for most of what ts(1) offers. ("-1" makes the embedded strftime(3) format string assume the current time as its input).
Re:The Hidden Gems of Moreutils by smalu on Saturday December 30, 2023 @02:33PM (#38818237)
I recommend zmwangx/ets package, it is the modern version of ts. I'm using it in CI/CD pipeline in gitlab for debugging performance.
Re:The Hidden Gems of Moreutils by pdimitar on Monday January 01, 2024 @05:29PM (#38835913)
Thanks a lot for the link, I needed an improved `ts` for a long time now.
Re:The Hidden Gems of Moreutils by loeg on Saturday December 30, 2023 @02:34PM (#38818242)
The ‘logger’ command can also be useful.