I can't seem to get this script to work. I am trying to query the amount of cpu's on a list of nodes in a file.
readarray fnames < nodes.txt
for fn in "${fnames[@]}"
do
com="ssh $fn `cat /proc/cpuinfo | grep processor | wc -l`"
com=${com: -2}
echo $fn $com
done
It should print the hostname than number of cpu's. Instead it prints the hostname and 8 every time. I suspect the 8 is because of
bash: 8: command not found
being displayed.
cat /proc/cpuinfo | grep processor | wc -lfor the current hostname, which why it always returns 8.