【问题标题】:Trying to extract the numbers from an output of Raspberry PI DHT 22 sensor尝试从 Raspberry PI DHT 22 传感器的输出中提取数字
【发布时间】:2020-03-20 22:43:40
【问题描述】:

DHT 22 这样输出温度和湿度

温度=24.8* 湿度=46.6%

现在我正在尝试使用 'sed' 来提取

1) 温度 24.8

2) 湿度46.6

在 bash 命令行中,因此我可以将其作为变量 $t 和 $h 进行进一步处理。

我无法构建 sed 以提取第一个数字 (temp) 和第二个数字(湿度)。你能帮我么。几个小时后,我现在迷路了。

【问题讨论】:

    标签: bash sed raspberry-pi


    【解决方案1】:

    从文件 wehre 中执行 grep 和 sed

           1) grep -ozP 'Temp=....' hum.txt | sed -e 's/Temp=//g'
    

    湿度也是如此。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-15
      • 2017-04-13
      • 1970-01-01
      • 2022-09-24
      • 2016-09-14
      • 2013-07-15
      相关资源
      最近更新 更多