0

I'm trying to make a program that will monitor my CPU cores over time, using a little shell as I'm trying to learn it.

  1. I want to determine the # of cores
  2. I then want to create a column for each core, so that I can add the data to each core when I collect it.

The csv file would create the columns like: Core1, Core2, Core3, Core4, Core5, Core6, Core7, Core8

#!/bin/sh

cores=grep -c ^processor /proc/cpuinfo #Shows I have 8 cores

touch core_monitor.csv #make csv file

echo core{1..cores}, >> core_monitor.csv
#This echo doesn't work. it prints the string literal `core{1..cores},`
dftag
  • 77
  • 1
  • 6
  • U could use `eval "printf -v out %s core{1..$cores},";echo ${out%,}`, but **.1** not under [tag:shell], because it's *bashism*, and **.2** It's a *not so good idea* as `eval` is evil! – F. Hauri Mar 26 '22 at 07:57

0 Answers0