News for hackers. Stuff that matters.
Re:The Unix `Who` Command by MisterTea on Thursday September 03, 2020 @10:23AM (#24364342)
plan 9 who is a 3 line shell script that just greps the output of ps and sorts it. You could eliminate ps and just grep through /proc but why reinvent the wheel when an existing tool already does part of the job?

I see some comments here citing a lack of options, most of which appear to have nothing to do with who is logged into the machine.

Re:The Unix `Who` Command by forgotpwd16 on Thursday September 03, 2020 @12:22PM (#24365624)
Source for the mentioned script: https://github.com/0intro/plan9/blob/master/rc/bin/who. Also, other utilities implemented as scripts are fshalt (P9's shutdown), kill, lookman (P9's apropos), uptime and whois.
Re:The Unix `Who` Command by jf on Thursday September 03, 2020 @12:33PM (#24365755)
Does anybody know why there are line breaks in the sed command?
Re:The Unix `Who` Command by forgotpwd16 on Thursday September 03, 2020 @01:40PM (#24366506)
It runs multiple expressions. That is

  sed '/pattern1/d
  pattern2/d'
is the same with

  sed '/pattern1/d; /pattern2/d'
and

  sed -e '/pattern1/d' -e '/pattern2/d'
I believe those are portable across all `sed` implementations, and they at least work with GNU `sed --posix` and plan9port's sed.
Re:The Unix `Who` Command by jf on Thursday September 03, 2020 @09:48PM (#24370968)
Thank you! This is exactly the kind of reply I was hoping for.
Re:The Unix `Who` Command by fizzled on Thursday September 03, 2020 @11:20AM (#24364878)
Is /proc as portable as `ps`?
Re:The Unix `Who` Command by JdeBP on Thursday September 03, 2020 @04:06PM (#24368268)
There's a long explanation when it comes to ps, but the very short answer is twofold:

* Don't parse the output of ps, unless it is my ps command (or plan 9's one, as here). See https://unix.stackexchange.com/a/593198/5132 and https://unix.stackexchange.com/a/578816/5132 , and their further reading, especially Greg Wooledge's article.

* /proc is as portable as ps, but that doesn't really amount to much because neither is really portable at all. Pretty much every operating system's /proc is different; and no implementation of the ps command fully conforms to even the limited subset laid out in the Single Unix Specification.

Re:The Unix `Who` Command by hibbelig on Thursday September 03, 2020 @03:56PM (#24368144)
I guess that Linux `/proc` is different from Plan 9 `/proc`, and Linux `ps` is different from Plan 9 `ps`.

So maybe yes.