Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Work with tail -f #1

Open
SimenB opened this issue Feb 20, 2017 · 6 comments
Open

Work with tail -f #1

SimenB opened this issue Feb 20, 2017 · 6 comments

Comments

@SimenB
Copy link

SimenB commented Feb 20, 2017

Would it be possible for this to work on stdin as well?

I'd like to tail a log and send it into this, and be able to interactively filter it. jq handles stdin just fine, if that matters 😄

@fiatjaf
Copy link
Owner

fiatjaf commented Feb 20, 2017

Well, it does work with stdin content. Actually, it only works with stdin, I think. It should work with other types of input.

echo {} | jiq actually raises an error, but it shouldn't. However, echo {"a": "b"} | jiq and other valid JSON over stdin works well. What error are you seeing?

@SimenB
Copy link
Author

SimenB commented Feb 21, 2017

Yeah, that was imprecise of me, sorry.
What I meant is e.g. tailing a log using the follow option. If I do tail -f something.json | jq, jq will also format anything new added to the something.json file. If I pipe into jiq though, I never get anything at all. Not even the original content of the file.

My real use case is that I currently tail a log and send it into jq for formatting, which works fine, but I'd also like to be able to apply filters on the fly, instead of restarting jq all the time.

Does that make sense?

@SimenB SimenB changed the title Work on stdin Work with tail Feb 21, 2017
@SimenB SimenB changed the title Work with tail Work with tail -f Feb 21, 2017
@fiatjaf
Copy link
Owner

fiatjaf commented Feb 21, 2017

Oh, I see it now. This seems complicated. I don't know how tail -f works, nor how jq does what it does. It doesn't seem to work if you modify an existing JSON object on the file, only if you add a new line, right?

Sorry, but I think I will not be able to include this feature anytime soon, but if you (or anyone else) did a PR I would be glad to merge it.

@SimenB
Copy link
Author

SimenB commented Feb 21, 2017

Yes, just adding a new line. And logs are append only, so no real issue.

Ok, that's fine 😄

@fiatjaf
Copy link
Owner

fiatjaf commented Feb 21, 2017

It has something to do with reading Stdin as a stream, right? It shouldn't be difficult.

@SimenB
Copy link
Author

SimenB commented Feb 21, 2017

Yup, sounds right.
I don't know Go at all, so won't be able to provide a PR, unfortunately.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants