【发布时间】:2016-01-27 01:56:34
【问题描述】:
TL:DR 我想要紧跟“+”号的任何行的前两个数字的语法。
给定以下文本(来自熟悉的实用程序):
power_meter-acpi-0
Adapter: ACPI interface
power1: 4.29 MW (interval = 4294967.29 s)
coretemp-isa-0000
Adapter: ISA adapter
Physical id 0: +44.0°C (high = +75.0°C, crit = +85.0°C)
Core 0: +36.0°C (high = +75.0°C, crit = +85.0°C)
Core 1: +38.0°C (high = +75.0°C, crit = +85.0°C)
Core 2: +36.0°C (high = +75.0°C, crit = +85.0°C)
Core 3: +36.0°C (high = +75.0°C, crit = +85.0°C)
Core 4: +37.0°C (high = +75.0°C, crit = +85.0°C)
Core 5: +36.0°C (high = +75.0°C, crit = +85.0°C)
coretemp-isa-0001
Adapter: ISA adapter
Physical id 1: +43.0°C (high = +75.0°C, crit = +85.0°C)
Core 0: +36.0°C (high = +75.0°C, crit = +85.0°C)
Core 1: +38.0°C (high = +75.0°C, crit = +85.0°C)
Core 2: +36.0°C (high = +75.0°C, crit = +85.0°C)
Core 3: +37.0°C (high = +75.0°C, crit = +85.0°C)
Core 4: +36.0°C (high = +75.0°C, crit = +85.0°C)
Core 5: +37.0°C (high = +75.0°C, crit = +85.0°C)
我需要找出有趣的数字,即 44、36、38、36、36、37 等...
在 Linux 的命令行中,我使用了sensors | awk '{ print $3 }' | egrep -o '\+..' | sed 's/^.//',它输出了 14 个有趣数字中的 12 个,但并不那么优雅。
【问题讨论】:
-
sensors | sed -r 's/^.*\+([[:digit:]]+)\.[[:digit:]].C .*/\1/' -
@EdMorton 这是“太长了,没看过” - 提供一个摘要。
标签: linux awk command-line grep