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 (for example) 8
(whereas the command above would return 16
)
More Related Contents:
- How to get overall CPU usage (e.g. 57%) on Linux [closed]
- How to create a CPU spike with a bash command
- grep lines that contain 1 character followed by another character
- How to convert DOS/Windows newline (CRLF) to Unix newline (LF) in a Bash script
- Bash script prints “Command Not Found” on empty lines
- What’s the magic of “-” (a dash) in command-line parameters?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Is there a “goto” statement in bash?
- How can I generate new variable names on the fly in a shell script?
- What’s the difference between nohup and ampersand
- Bash while read loop extremely slow compared to cat, why?
- Redirect STDERR / STDOUT of a process AFTER it’s been started, using command line?
- Find multiple files and rename them in Linux
- Using the passwd command from within a shell script
- Command to get time in milliseconds
- How to create a hex dump of file containing only the hex characters without spaces in bash?
- linux: kill background task
- Syntax with pound and percent sign after shell parameter name [duplicate]
- What is the difference between double-ampersand (&&) and semicolon (;) in Linux Bash?
- How do I script a “yes” response for installing programs?
- Get ceiling integer from number in linux (BASH)
- Print date for the monday of the current week (in bash)
- How can I trim white space from a variable in awk?
- How do you filter out all unique lines in a file?
- How to automatically add user account AND password with a Bash script?
- Meaning of tilde in Linux bash (not home directory)
- How to convert hex to ASCII characters in the Linux shell?
- How to check if a program is run in Bash on Ubuntu on Windows and not just plain Ubuntu?
- What are the rules for valid identifiers (e.g. functions, vars, etc) in Bash?
- Bash `wait` command, waiting for more than 1 PID to finish execution