Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a CSV list from Linux 'ps'

Tags:

linux

csv

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.

like image 954
Paul Nathan Avatar asked Jun 25 '10 00:06

Paul Nathan


People also ask

How do I create a CSV file in Linux?

Once open, click File and choose Save As. Under Save as type, select CSV (Comma delimited) or CSV (Comma delimited) (*.

How create CSV file in Terminal?

To do this, just add the > character and the name of the file where you want the output to be stored to the end of the command. If the output file doesn't already exist, > will create that file. If that file exists, > will replace its contents with the new output.

What does ps EF command do in Linux?

The “-ef” option of the “ps” command is used to print all the processes running on the system in the standard format.


1 Answers

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

ps -Ao "%U,%t,%a"
like image 113
emx Avatar answered Sep 17 '22 22:09

emx