我正试图将计算机的温度存储在一个变量中。我试过了,但不起作用:
#!/bin/bash
temp = cat "/sys/class/thermal/thermal_zone0/temp"
echo "$temp"
我也试过这个:
#!/bin/bash
temp = $(cat "/sys/class/thermal/thermal_zone0/temp")
echo "$temp"
但什么都不管用,它总是说
./temp.sh: line 2: temp: command not found
空间至关重要!这很好:
# NO space around `=`
temp=$(cat "/sys/class/thermal/thermal_zone0/temp")
echo "$temp"