我必须将 top 命令的输出保存到一个变量中,我这样做:
myvar=`top -b -n1 | head -n 18`
问题是它似乎忽略了返回字符,所以当我回显的内容时,$myvar
我看到如下内容:
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...
如何正确保存所有顶级数据?