开发者

How do I list the output of ps -U root -u root -eo pid in a single line seperated by comma's

when I execute the cmd ps -U root -u root -eo pid I get the output in multiple lines

Eg: 1 2 3 4

I would like to see the output in one line as 开发者_StackOverflow中文版1,2,3,4,5 ...


One possible way is

ps -U root -u root -eo pid | tr -s "\n" ","


No need external command

var=$(ps -U root -u root -eo pid )
echo ${var//$'\n'/,}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜