문제

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