I've got to save the output of the top command into a variable and I do this:
myvar=`top -b -n1 | head -n 18`
The problem is that it seems to be ignoring the return characters, so when I echo the content of $myvar
I see something like:
top - 15:15:38 up 745 days, 15:08, 5 users, load average: 0.22, 0.27, 0.32 Tasks: 133 total, 1 running, 132 sleeping, 0 stopped, 0 zombie Cpu(s): 6.4% us, 1.6%sy, 0.0% ni, 91.7% id, 0.3% wa, 0.0% hi, 0.0% si Mem: 2074716k total, 2038716k used, 36000k free, 84668k buffers Swap: 4192924k total, 107268k used, 4085656k etc...
How can I save all top data correctly?
Thanks a lot.