我使用这样的命令:
test@localhost:~> cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 23
model : 1
model name : AMD Ryzen 5 1600 Six-Core Processor
stepping : 1
microcode : 0x8001138
cpu MHz : 1376.637
cache size : 512 KB
physical id : 0
siblings : 12
core id : 0
cpu cores : 6
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca
bugs : sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass
bogomips : 6387.25
TLB size : 2560 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual
power management: ts ttp tm hwpstate eff_freq_ro [13] [14]
...
例如,如果我想获取字段的值cpu MHz
,那么我会写...并得到...
使用哪个脚本。这是另一个例子:
test@localhost:~> sensors
amdgpu-pci-0800
Adapter: PCI adapter
vddgfx: +0.84 V
fan1: 839 RPM (min = 0 RPM, max = 3200 RPM)
edge: +43.0°C (crit = +94.0°C, hyst = -273.1°C)
power1: 39.05 W (cap = 175.00 W)
k10temp-pci-00c3
Adapter: PCI adapter
Vcore: +0.92 V
Vsoc: +1.08 V
Tdie: +46.2°C
Tctl: +46.2°C
Icore: +14.00 A
Isoc: +9.75 A
如何准确得到min Rpm
和max Rpm
?
答案1
grep
例如,使用grep "cpu MHz" /proc/cpuinfo
来选择线路。用于sed
从行中提取一些文本,例如删除冒号之前的所有内容。将它们与管道 ( |
) 结合起来即可完成这两项操作。
grep "cpu MHz" /proc/cpuinfo | sed -e "s/^.*: //"