Вопрос

I'm trying to store the number of CPUs in a variable for a linux bash shell. I know nproc returns the number of CPUs however I can't seem to store the value returned in a variable.

I'm sure it's a simple solution so any help would be appreciated.

Thanks

Это было полезно?

Решение

Just use nested call to nproc:

$ NPROC=$(nproc)
echo $NPROC
1
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top