Good point. @octopus Are you trying to remove just the ":", or the ":" and the degree symbol?sed 's/://'
You have wrong charecter in your sed
cat /proc/dmu/temperature | hd
00000000 43 50 55 20 74 65 6d 70 65 72 61 74 75 72 65 09 |CPU temperature.|
00000010 3a 20 38 35 f8 43 0a 0a |: 85.C..|
Thats give:cpu="$(cat /proc/dmu/temperature | sed 's/\t: /XXXXX/ ; s/øC$/YYYYY/')"
Notice how the " : " is actually <tab><colon><space>Code:cat /proc/dmu/temperature | hd 00000000 43 50 55 20 74 65 6d 70 65 72 61 74 75 72 65 09 |CPU temperature.| 00000010 3a 20 38 35 f8 43 0a 0a |: 85.C..|
Prefered output is: CPU temperature 75 degrese
cat /proc/dmu/temperature | sed -r 's/\t: // ; s/([0-9]{1,3})/ \1 degrese/'
Code:cat /proc/dmu/temperature | sed -r 's/\t: // ; s/([0-9]{1,3})/ \1 degrese/'
When tested from xshell i get this out:
octopus@RT-AC68U:/tmp/home/root# cat /proc/dmu/temperature | sed -r 's/\t: // ; s/([0-9]{1,3})/ \1 degrese/'
CPU temperature 75 degrese
But when in this case sending mail I get signs at then end: " øC "
CPU temperature 75 degreseøC
Thanks !
# cpu="$(printf "The temperature is %s degrees" $(cat /proc/dmu/temperature | sed 's/[^0-9]*//g'))"
# echo $cpu
The temperature is 82 degrees
When tested from xshell i get this out:
octopus@RT-AC68U:/tmp/home/root# cat /proc/dmu/temperature | sed -r 's/\t: // ; s/([0-9]{1,3})/ \1 degrese/'
CPU temperature 75 degrese
But when in this case sending mail I get signs at then end: " øC "
CPU temperature 75 degreseøC
sed -r 's/\t: // ; s/([0-9]{1,3})/ \1 degrese/ ; s/C$//' | tr -d '\xf8'
Thank you!Not strictly 'sed'
Code:sed -r 's/\t: // ; s/([0-9]{1,3})/ \1 degrese/ ; s/C$//' | tr -d '\xf8'
2.4Ghz radio 50 Grader
5.0Ghz radio 52 Grader
CPU temperature 76 Grader
Thanks, that is also a solution and I can use my own text.Code:cat /proc/dmu/temperature | cut -d ":" -f 2
Code:cat /proc/dmu/temperature | cut -d ":" -f 2
cat /proc/dmu/temperature
CPU temperature : 74
cat /proc/dmu/temperature | cut -d ":" -f 2 | wc -c
7
It's only invisible because you are using an incompatible character set (the last "C" should always be visible anyway). So if you use ISO-8859-15 for example:Your code returns the spurious 2-char unwanted suffix that is invisible i.e. non-printable
# cat /proc/dmu/temperature
CPU temperature : 84øC
cpu="`cat /proc/dmu/temperature | sed -r 's/\t: // ; s/([0-9]{1,3})/ \1 Grader/ ; s/C$//' | tr -d '\xf8'`"
use completely different text
cpu="$(printf "CPU temperature %s Grader" $(cat /proc/dmu/temperature | sed 's/[^0-9]*//g'))"
#!/bin/bash
celsius=$(cat /sys/class/thermal/thermal_zone0/temp | sed 's/.\{3\}$/.&/')
echo "ARM Temp => ${celsius} °C"
That's handy, my 86U is at 68.458 °C, ambient temperature 23 °C.ARM Temp => 53.692 °C
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!