How to save the value returned by nproc in linux shell?

I am trying to save the number of processors in a variable for linux bash shell. I know that nproc returns the number of processors, but I cannot save the value returned by the variable.

I am sure this is a simple solution, so any help would be appreciated.

thank

+3
source share
1 answer

Just use the nproc nested call :

$ NPROC=$(nproc)
echo $NPROC
1
+5
source

All Articles