tags:

views:

12

answers:

2

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 1,2,3,4,5 ...

+4  A: 

One possible way is

ps -U root -u root -eo pid | tr -s "\n" ","
Raghuram
Thanks, I was using the ps -U root -u root -eo pid | tr -s \n , . No quotes and it makes one hell of a differernce
Eternal Learner
A: 

No need external command

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