0

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 ...

2 Answers 2

4

One possible way is

ps -U root -u root -eo pid | tr -s "\n" ","
1
  • 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 Oct 8, 2010 at 4:55
0

No need external command

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.