本文介绍了从Linux的'ps'生成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

我想说服ps用逗号(或者甚至是制表符)分隔,以便它可以被其他语言自动处理。请注意,args中可能会有空格,因此,awks by field将不会工作。

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"

这篇关于从Linux的'ps'生成CSV列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 05:25