我对grep和sed命令相当新颖。如何使用grep或sed在bash脚本中从Core 0: +50.0°C (high = +80.0°C, crit = +90.0°C)
中提取+50.0
?使用sed或grep解压缩
acpitz-virtual-0
Adapter: Virtual device
temp1: +50.0°C (crit = +89.0°C)
temp2: +50.0°C (crit = +89.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +50.0°C (high = +80.0°C, crit = +90.0°C)
Core 2: +47.0°C (high = +80.0°C, crit = +90.0°C)
bash脚本:
#!/bin/bash
temp=`sed -n '/^Core 0: $/,/^(high/p' ~/Desktop/sensors.txt`
echo $temp
你有什么需要提取的更具体的规则?它是否总是在Core 0之后立即在'之前'('? –
我只想提取Core 0之间的任何内容:(如果可能的话,消除Core 0:和+50.0之间的额外空间动态) –