I currently have this code:
cat /proc/cpuinfo | grep "MHz" | cut -d ':' -f2 | sed 's/.*/Core NUM&Mhz/'
Which outputs the following (for 8 cores):
Core NUM 1941.054Mhz
Core NUM 1949.820Mhz
Core NUM 2022.734Mhz
Core NUM 1877.171Mhz
Core NUM 1938.265Mhz
Core NUM 1945.703Mhz
Core NUM 1845.562Mhz
Core NUM 1781.546Mhz
What I want to do is replace "Core NUM" with actual numbers (e.g. Core 0, Core 1, Core 2, Core 3...) I would prefer a solution that can be done on one line with the rest of this command, but since I am in the end working from a bash script, I don't mind a multi-line/scripted solution either. The biggest problem I guess is that grep is one command outputting many lines, and I don't know if there's a way to target these lines one by one in something like a for or while loop.
So, how can I do this?
grep
,cut
andsed
withawk
and getawk
to print the line numbers as well - someone will be along soon with anawk
solution, I'm sure./proc/cpuinfo
as/proc/procinfo
and wondering why it wasn't there.cpupower
for that, don't you ? e.g.cpupower -c all frequency-info -fm
or, to format it per your questioncpupower -c all frequency-info -fm | paste -d' ' - - | cut -c11-
(assuming en_US locale)