Hi all.
I’m trying to grep the state from my Sonoff using curl, but I can’t figure out how to isolate the state exactly.
The text I’m grepping from
{"POWER":"OFF"}
It is the word ON or OFF i need to isolate, and convert them to small letters.
I have tried using below but it dose not work.
curl --silent "http://192.168.3.136/cm?cmnd=Power" | grep '{"POWER":"' | cut -d '=' -f2 | cut -c 2- | tr A-Z a-z
Anyone here strong in grep?
Thank you for your help 😊
EDIT: @simonbove I have edited your post to mark the command snippet as code. If the normal HTML format is used straight quotes will be replaced with curly quotes and, thus, pasting the snippet to a command shell will cause errors in most cases. Please see the following topic on the matter for future posts. Thanks!
https://forum.pimatic.org/topic/1179/how-to-post-code-snippets-and-alike-on-the-forum