Jonathan Jonathan - 1 year ago 81
Linux Question

How to pull only the value from lscpu in Linux?

If i want to get the CPU Mhz I use.

lscpu | grep "CPU MHz"
# CPU MHz: 1200.031

I only want to keep the 1200.031, how would I filter the CPU MHz: in the terminal?

Answer Source

To remove the leading whitespace leaving only the MHz value, you can do:

lscpu | sed -n 's/CPU MHz:[ \t]*//p'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download