Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

I have the script, but I do not know how to get this last element in one printout:

cat /proc/cpuinfo | awk '/^processor/{print $3}'

The last element should hold the number of CPUs, minus 1.

1 Answer

0 votes
by (36.8k points)
edited by

Use the below command:

grep -c ^processor /proc/cpuinfo     

will count the number of lines starting with

"processor" in /proc/cpuinfo

For systems with hyper-threading, you can use

grep ^cpu\\scores /proc/cpuinfo | uniq |  awk '{print $4}' 

which should return  8 

To know about Linux join the Linux training

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...