Skip to content

ps: add lots of sorting functions

Topi Miettinen requested to merge topimiettinen/procps:ps-sort-label into master

Add a macro for using the print function also for sorting, use it for sorting with label as key.

Before:

$ ps -A -o command,label --sort label |grep /lib/systemd
/lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0
/lib/systemd/systemd-udevd  system_u:system_r:udev_t:s0-s0:c0.c1023
/lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0
/lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0
/lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0
/lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0
/lib/systemd/systemd --user user_u:user_r:user_t:s0
/lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023
grep /lib/systemd           user_u:user_r:user_t:s0

After:

$ ps -A -o command,label --sort label |grep /lib/systemd
/lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023
/lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0
/lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0
/lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0
/lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0
/lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0
/lib/systemd/systemd-udevd  system_u:system_r:udev_t:s0-s0:c0.c1023
/lib/systemd/systemd --user user_u:user_r:user_t:s0
grep /lib/systemd           user_u:user_r:user_t:s0

Signed-off-by: Topi Miettinen toiwoton@gmail.com

Edited by Craig Small

Merge request reports