Provide a way to specify custom column delimiter
This is less of bug report and more of feature request.
I need to produce ps machine-readable output. The default column separator - space - is not working great when ps column value can contain spaces too(for example comm).
You can hack this by supplying multiple "-o" for ps, for example this works:
[root@au10 /]# ps --no-headers -a -o "cls" -o "|%p" -o "spid"
TS|22240 22240
however, this does not work for every column name, only for those that contain "%" in the name
[root@au10 /]# ps --no-headers -a -o "cls" -o "|tid"
error: unknown user-defined format specifier "|tid"
What is the recommended way to not mix up spaces in fields and column-delimiter spaces?
There are many ways to approach this:
- Create an option for column delimiter
- Create 'literal string' syntax for -o, maybe smth like this:
-o "pid','tid"
- Extend
-o
to support any non-ascii prefixes for column name: `-o "pid" -o",tid" - Allow
-o
that have no column name, just literal value:-o "pid" -o"," -o "tid"
- Create a special mode for ps to output machine-readable format(json? csv?)
- Your option?
Edited by Andrew Gurinovich