3 ms·
This is where you need to use awk. awk -F ':' '/cpu cores/ {a = $2 + 1} END {print a}' /proc/cpuinfo
by rakoo 6y ago
This is where you need to use awk.
awk -F ':' '/cpu cores/ {a = $2 + 1} END {print a}' /proc/cpuinfo
- lsofzz 6y ago> This is where you need to use awk. I think need is a strong statement in this context. echo $(( 1 + $(grep 'cpu cores' /proc/cpuinfo | head -1 | awk -F ':' '{print $2}') )) Choosing shell vs. [insert modern] programming is a matter of trade-off of taste, time, $$$, collective consensus (in a team setting) and so forth. [edit]: Forgot code syntax on HN.