21

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?

1
  • Seems to be rather easy to solve with a shell script :-) What does file $(type -p ts) return on your Linux system?
    – nohillside
    Apr 19, 2018 at 19:43

1 Answer 1

33

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/

1
  • This clashes with other packages like parallel and sponge 😕 Sep 7, 2022 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .