How to get `ts` program on the mac

On linux there is a great command line program ts. It adds a timestamp to the beginning of each line of input.

Here is an example (on some linux machine):

root@227ee318bbc1:~# echo -e '1\n2\n3'
1
2
3
root@227ee318bbc1:~# echo -e '1\n2\n3' | ts
Apr 19 18:59:52 1
Apr 19 18:59:52 2
Apr 19 18:59:52 3
root@227ee318bbc1:~#

But there is no such program on my mac:

bessarabov@air:~$ echo -e '1\n2\n3' | ts
-bash: ts: command not found

And there is no program with such name in brew.

How can I get ts program on my mac?


Solution 1:

Try brew install moreutils and then run the ts command. moreutils installs a bunch of things.

https://rentes.github.io/unix/utilities/2015/07/27/moreutils-package/