[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Sat, May 26, 2007 at 07:06:25PM +0100, Simon Williams wrote:
> Sorry for the semi-silly question- I really should learn sed properly.
>
> lm_sensors prints lines like this:
> fan1: 5273 RPM (min = 0 RPM, div = 8)
> fan2: 0 RPM (min = 0 RPM, div = 8)
> fan3: 0 RPM (min = 0 RPM, div = 2)
> M/B Temp: +27C (low = +15C, high = +40C) sensor = thermistor
> CPU Temp: +34C (low = +15C, high = +45C) sensor = thermistor
> Temp3: +54C (low = -1C, high = -1C) sensor = thermistor
>
> What I want is the fan1 speed (just "5273") and all 3 temperatures- as
> "27" (without the + or C).
>
> I will be grepping out the line I want, so sed only has to deal with
> single lines.
>
> I've been using cut for things like this before, but it's not really up
> to the job anymore.
I believe `awk` is better for the job, but I've never learned `awk`, so:
# Speed:
some_command | sed 's/^fan[0-9]\+: *\([0-9]\+\) RPM.*/\1/'
# Temp:
some_command | sed 's/[^:]*: *+\([0-9]\+\)C.*/\1/'
bma
--
Benjamin A'Lee <bma@xxxxxxxxx>
http://bmalee.eu/~bma/
"You are not entitled to your own opinion. You are only entitled to your own
entitled to your own informed opinion." - Gustave Flaubert
Attachment:
signature.asc
Description: Digital signature
-- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html