Problem with GPIO 1-Wire temperature sensors and Bash Script

I have several temperature sensors on my Raspberry connected to GPIO. They work fine and I get the temperature values from the sensors in the files named “…/w1_slave”.
Content of this file is for example:

86 01 4b 46 7f ff 0c 10 f4 : crc=f4 YES
86 01 4b 46 7f ff 0c 10 f4 t=24437

The string t=24437 represents the temperature of 24.437 °C

Now I want to show the temps in my Basic UI

I found a bash script that reads the temperature values out of the files

wert=‘cat /sys/bus/w1/devices/$1/w1_slave | tail -n1 | cut -d “=” -f2’
wert2=‘echo “scale=3; $wert/1000” | bc’
echo $wert2
(Hint: The ’ - characters are only shown here because I can´t use the original accent characters in this forum)

But this script causes linux to show the error:
(standard_in) 1: illegal character: ^M

So I wrote a test script that shows the value of the Sensor and also the hex-converted value

wert=cat /sys/bus/w1/devices/$1/w1_slave | tail -n1 | cut -d "=" -f2
echo $wert
echo “hex:” cat /sys/bus/w1/devices/$1/w1_slave | tail -n1 | cut -d "=" -f2 | xxd -p
The output is:
hex: 32343433370a

So the temperature is read correctly (24.437 °C) but there is the disturbing linefeed “0a” at the end.

How can I get the temperature value without that linefeed character?

Why not just use the GPIO OneWire binding?

Alternatively, you could just dos2unix the file.

I am working on a OneWire module for MQTTany that would allow you to get readings from the sensors over MQTT. This would simplify things for you and also means that openHAB doesn’t need to be running on the same Raspberry Pi that the sensors are connected to. I am hoping to have the module ready in the next week or two.

I tried at first.
But when I activated the binding and configured the Address “localhost” in the PaperUI an error showed up, same with “”
So it must have something to do with a missing “OWFS Bridge” which is mentioned at the docs for the OneWire-Binding…
So do you probably know a link to a step by step tutorial for bringing OneWire Temperature Sensors to work properly? But I don´t want to configure them in the paper UI because I want a transparent openhab 2 configuration which I also can backup easily, which imho is too complicated in a mixed manual/PaperUI config environment.