Command similar to watch

Hi all,

I am trying to create a file that shows the CPU usage, constantly updating (similar to TOP).

So far i have a file (called test) containing:

echo "The current CPU usage is:" `ps -e -o pcpu|awk 'NR > 0  { s +=$1 }; END {print s"%"}'`

and then I ran the command:

watch -d 0.5 -t ./test

This works perfectly, however it runs at full screen. I would like it just to update the line, as I will have other information around it.

Any ideas?? :confused:

Might want to try using vmstat.
this will display stats every minute. You can pull out the cpu usage.

vmstat 60 1440 
while :
do
  ps -e -o pcpu |
    awk 'NR > 0 { s +=$1 }
         END {printf "\rThe current CPU usage is: %s% ", s }'
  sleep 1
done

Perfect, thanks cfajohnson!