Here’s a fun little project that is a pretty good combination of array use and pattern manipulation.
#!/bin/bash function get_mhz() { while read line; do if [[ $line =~ cpu\ MHz ]]; then local hunks=(${line}) local ahz=(${hunks[3]}) local bars=$(( (${ahz%%.*} * (${COLUMNS} - 12) )/3500)) printf "%s:%${bars}s\n" $ahz '=' | tr ' ' '=' fi done < /proc/cpuinfo } while [[ 1 = 1 ]]; do stty_line=(`stty size`) COLUMNS=${stty_line[1]} get_mhz | sort -rn echo "" sleep 1 done
I could go on and on about it, but I’d rather you just ask me questions.
ARMv7 processors do not report this in /proc/cpuinfo. You can find it in
/sys/bus/cpu/devices/cpu0/cpufreq/scaling_cur_freq