Reputation: 103
the api for Particle.io says you can curl https://api.particle.io/v1/devices/events?access_token=[token]
to see an event log. This works great, except they seem to print newlines with regularity, so I end up with a couple log messages and a ton of newlines.
I'd love to grep the output to trim the newlines (grep -A3 event
would be perfect), but when I pipe curl to grep, I get nothing. (I've suppressed the progress indicator with -s). To make sure I'm not mistyping anything, I piped the curl output to cat, and I still get nothing (it initially prints :ok when just not piping, so it's clear whether it worked pretty quickly or not).
My guess is curl doesn't feed the data through the pipe until it completes downloading the target (which will never happen in this case).
Is there any way I can grep curl like this?
Upvotes: 0
Views: 799
Reputation: 51029
The curl
utility takes a -N
command line argument that unbuffers the output, so try:
curl -s -N ... | grep -A3 event
and that should do what you want.
Upvotes: 1