Note the difference:
#! /bin/bash x=`top -b -n 1 | head -n 5` echo $x echo -------------------- echo "$x"
Output:
top - 14:33:09 up 7 days, 5:58, 4 users, load average: 0.00, 0.00, 0.09 Tasks: 253 total, 2 running, 251 sleeping, 0 stopped, 0 zombie Cpu (s): 1.6% us , 0.4% sy, 70.3% ni, 27.6% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st Mem: 3926784k total, 3644624k used, 282160k free, 232696k buffers Swap: 9936160k total, 101156k used, 9835004k free, 1287352k cached
--------------------
top - 14:33:09 up 7 days, 5:58, 4 users, load average: 0.00, 0.00, 0.09
Tasks: 253 total, 2 running, 251 sleeping, 0 stopped, 0 zombie
Cpu (s): 1.6% us, 0.4% sy, 70.3% ni, 27.6% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st
Mem: 3926784k total, 3644624k used, 282160k free, 232696k buffers
Swap: 9936160k total, 101156k used, 9835004k free, 1287352k cached
Without quotes, the contents of the variable are based on the processing of shell arguments.