CODE
ps -Aco time,user,command | mawk NF=NF OFS=','
# lower-case -o for basic columns
# upper-case -O for info overloading
OUTPUT
- (sample only, not identical to OP's)
TIME,USER,COMMAND
20:13.26,root,launchd
3:53.13,root,logd
0:32.95,root,UserEventAgent
0:04.87,root,uninstalld
6:58.58,root,fseventsd
0:02.48,root,mediaremoted
4:02.23,root,systemstats
I dunno what variant of ps
OP might have, whether flags -Aco
work or not - i can only speak about my experience on macos 12.4
————————————————
In fact, set OFS
to anything delimiter you like - personally I usually love equal sign [ =
] as a field delimiter
individual field strings can go completely unquoted,
- even if it has spaces, tabs,
unicodes
, even all sorts of random bytes
conversely, basically nothing needs to be escaped,
even for single- or double-quotes,
- except when field texts include [
=
] itself, then just find a random pair or triplet of bytes to escape [ =
]
reasonably safe choice when compared to just about any other ascii
[[:punct:]]
, since it's among the chars least likely to have
special meanings in shell
or any regex
engine, while still directly type-able from a QUERTY
keyboard
mawk NF=NF OFS==
\
yields
/
0:00.03=root=colorsyncd
0:54.30=root=searchpartyd
0:00.57=_appleevents=appleeventsd
0:00.92=root=findmydeviced
0:30.52=_networkd=symptomsd