On Sat 18 Feb 2023 at 09:53:01 (-0500), Greg Wooledge wrote: > It should be noted that there appear to be two TYPES of data fields: > numeric and string. Look at this example: > > unicorn:~$ ps -o '%C %g %n %p %U %a' > %CPU RGROUP NI PID USER COMMAND > 0.0 greg 0 1010 greg bash > 0.0 greg 0 2094243 greg ps -o %C %g %n %p %U %a > > The "%CPU", "NI" and "PID" fields are right-justified. The "RGROUP", > "USER" and "COMMAND" fields are left-justified. > > This means the header parser will also need to contain knowledge about > each header -- whether it's left-justified (string) or right- (numeric).
Oh, it's somewhat worse than that. You need to know the maximum length that can be shown for left-justified strings, and also what the maximum width of a numeric field is. But even that's not enough because the field width is somewhat variable: try ps -eo '%c | %z | %a' (We can still use | to make the problem somewhat more obvious.) > With all those pieces, I think the problem can be "solved", although I > wouldn't care to write such a thing. Time spent on writing that > parser/filter would be better spent advocating to restore the previous > functionality, IMHO. We don't know the priorities of the OP, and whether the example was somewhat simplified just for posing the question. If it wasn't, then quick and dirty might suffice. That's up to the OP, and what they consider the chances are of the "fix" being accepted. Much of man ps seems to be an exercise in vagueness. Somewhat. Cheers, David.