I want to capture the output of top to a file but there is a problem, the output is always the same. For example, the code below grabs the %CPU returned by the top command. The problem is that everytime I execute this code it shows the same %CPU usage, why?
top -n 1 | awk '/^%Cpu\(s\)/ {print $2}'