Redirect jq输出的重定向

Redirect jq输出的重定向,redirect,pipe,jq,Redirect,Pipe,Jq,在终端中,这可以正常工作: mosquitto|u sub-h 192.168.178.20-t tele/POW/SENSOR/|jq'.ENERGY | Power' 每10秒屏幕上就会有一个输出,因为设备POW每10秒发布一次传感器日期。mosquitto_sub(它是一个JSON字符串)的输出通过管道传输到jq,jq只显示键“Power”的值位。现在我尝试将jq输出(仅值)存储到文件“output.log”中 mosquitto_sub -h 192.168.178.20 -t tele

在终端中,这可以正常工作:

mosquitto|u sub-h 192.168.178.20-t tele/POW/SENSOR/|jq'.ENERGY | Power'

每10秒屏幕上就会有一个输出,因为设备POW每10秒发布一次传感器日期。mosquitto_sub(它是一个JSON字符串)的输出通过管道传输到jq,jq只显示键“Power”的值位。现在我尝试将jq输出(仅值)存储到文件“output.log”中

mosquitto_sub -h 192.168.178.20 -t tele/POW/SENSOR/# | jq '.ENERGY|.Power' > output.log
它不起作用。出了什么问题?

来自jq手册:

--unbuffered

Flush the output after each JSON object is printed 
(useful if you’re piping a slow data source into
jq and piping jq’s output elsewhere).