I am unable to capture CPU[3] to IDLE variable in shell script (/bin/sh)
Code snippet as below:-
while true; do
CPU=$(sed -n 's/^cpu\s//p' /proc/stat)
**IDLE=$CPU[3]** # Just the idle CPU time.
for VALUE in ${CPU} ;
do
TOTAL=$((TOTAL+VALUE))
printf "%s \n\n" $VALUE
sleep 1
printf "%s \n" $IDLE
done
sleep 0.1
done