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'/,}
精彩评论