tr -d removes characters based on pattern, not strings, so tr -d "0" will remove all zeroes by design. What is the output of cat /sys/class/drm/card0/device/hwmon/hwmon*/temp1_input? What make/model of GPU?
Assuming your output always has trailing ‘000’ as you hinted in your original post and replies (because I’m not otherwise familiar with those files), one minor issue with that solution is that if for example a gpu fan breaks and your GPU goes over 100°C, then the output of the above would be false (always 10<output<100).
for temp in 33000 4000 120000; do
echo $temp | cut -b -2 | awk '{sub("$", "°C", $1)}; 1'
done
33°C
40°C
12°C
One alternative if you need to handle that case could be (using sed):
for temp in 33000 4000 120000; do
echo $temp | sed 's/000$/°C/'
done
33°C
4°C
120°C
What is the terminology for this form of substitutions (using {})?
I’ve noticed this in eos scripts.
I would like to study a bit on it and learn it, just not sure how to google it