Generating a CSV list from Linux 'ps'


Suppose I have a ps command that looks like this:

ps -Ao args:80,time,user --sort time 

It will give me a “space” separated set of rows. A row might look like this

paulnath -bash 00:00:00

I would like to convince ps to delimit by commas(or tabs even!), such that it can be processed automagically by other languages. Please note that args will probably have spaces in it, so, awking by field won’t per se work.


You can use the following syntax to put your own delimiter:

ps -Ao "%U,%t,%a"

Answered By – emx

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published