答え1
二重引用符変数
echo "${top}"
割り当て後の試みtop="$(top -n1)"
答え2
コピーできません:
$ t="$( top -b -n1 )"
$ echo "$t" | head -n3
top - 14:49:52 up 243 days, 17:18, 2 users, load average: 0.03, 0.07, 0.12
Tasks: 205 total, 1 running, 203 sleeping, 1 stopped, 0 zombie
%Cpu(s): 2.4 us, 0.5 sy, 0.1 ni, 96.4 id, 0.7 wa, 0.0 hi, 0.0 si, 0.0 st