Page 1 of 1

Conky cosmetic - a little scripting question.

Posted: Sun Oct 27, 2024 2:24 am
by dcung

Most of my laptops, pcs, I find to get better picture of temp from reading CPU core.
So, I have this line in generic conky setup that reads it - from sensors command.

Code: Select all

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +38.0°C  (high = +87.0°C, crit = +105.0°C)
Core 0:        +39.0°C  (high = +87.0°C, crit = +105.0°C)
Core 1:        +32.0°C  (high = +87.0°C, crit = +105.0°C)

CMB1-acpi-0
Adapter: ACPI interface
in0:          12.20 V  
curr1:         0.00 A 

sensors | grep ^"Core 0" | awk '{print $3}'

Code: Select all

+39.0°C

I want to get rid of the +
How do I do that pls?


Re: Conky cosmetic - a little scripting question.

Posted: Sun Oct 27, 2024 3:41 am
by MochiMoppel
dcung wrote: Sun Oct 27, 2024 2:24 am

sensors | grep ^"Core 0" | awk '{print $3}'

Code: Select all

+39.0°C

I want to get rid of the +

You don't need grep when you use awk.
Try

Code: Select all

sensors | awk '$1$2=="Core0:" {print substr($3,2)}'

Re: Conky cosmetic - a little scripting question. <SOLVED>

Posted: Sun Oct 27, 2024 3:54 am
by dcung
MochiMoppel wrote: Sun Oct 27, 2024 3:41 am

You don't need grep when you use awk.
Try

Code: Select all

sensors | awk '$1$2=="Core0:" {print substr($3,2)}'

That works!
Thanks @MochiMoppel