April 2018
Beginner
284 pages
7h 3m
English
Another really useful feature is that grep can count the matching lines and not display them. We can use this to count the number of CPUs or CPU cores we have on a system. Each core or CPU is listed with a name in the /proc/cpuinfo file. We can then search for the text name and count the output; the -c option used is shown in the following example:
$ grep -c name /proc/cpuinfo
My CPU has four cores, as shown in the following output:

If we use the same code on another PC Model B that has a single core, we will see the following output:
We can again make use of this in a script to verify that enough cores ...