on one line

why does this output appear on one line

#!/usr/bin/bash
pid=$(ps -eo pid)
echo $pid

PID 0 1 2 3 145 7 9 640 149 108 150 5185 637 5076 223 643 642 641 140 844 228 235 237 254 257 787 638 362 402 294 789 5184 797 806 799 25612 809 811 815 25577 5183 25610

whereas if you do the command ps -eo pid from the command line each pid is on a newline?

deleted - poor information

Yep :smiley:

# pid=$(ps -eo pid)
# echo $pid
  PID
 2373
 2375
 2382
 2374
 1691
 1693
 2177
 2285
31892
43206
45009
10713
31911
31914
21759
34333
34677
# bash --version
GNU bash, version 4.0.10(1)-release (i386-portbld-freebsd7.2)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Back to the problem :cool:

#!/usr/bin/bash
pid=$(ps -eo pid)
echo "$pid"