3

Unlike Linuxae which outputs 2022-11-07 16:23, FreeBSD who command outputs Nov 7 16:23. How can I change the date format in the output of who either globally or just for the duration of the command?

Example output of who on FreeBSD 13.1-p3, in the POSIX locale (the date format changes with the locale):

me               pts/1        Nov  7 13:06 (192.168.1.107 via mosh [1964])
me               pts/2        Nov  7 13:07 (tmux(1988).%0)
me               pts/3        Nov  7 13:07 (tmux(1988).%1)
me               pts/4        Nov  7 13:07 (tmux(1988).%2)
me               pts/5        Nov  7 13:08 (tmux(1988).%3)
me               pts/7        Nov  8 07:09 (192.168.1.103 via mosh [2059])
me               pts/8        Nov  7 13:08 (tmux(1988).%4)

Note that while the date format changes with the locale, the date string in the output is created with strftime() using either %e %b %R or %b %e %R as format strings, which makes it impossible to "just use another locale".

0

1 Answer 1

1

You're correct, the date string output in 'who' is hard coded to those format strings in the source code and no locale changes will change it.

The only way to adjust them would be to modify the source code and re-build 'who' with your chosen format (or have some wrapper script around who to rewrite them, but that would be messy)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.