Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to not print records where the query would result in "null" #24

Closed
geoffeg opened this issue Oct 22, 2012 · 3 comments
Closed

Comments

@geoffeg
Copy link

geoffeg commented Oct 22, 2012

Throwing "grep -v null" on the end of the command is easy enough, but in many (most?) situations where i'm doing a query on a field name, I don't want records where the query would result in a non-match on the record.

@stedolan
Copy link
Contributor

jq 'foo | select(. == null | not)'

should do the trick

@geoffeg
Copy link
Author

geoffeg commented Oct 22, 2012

Hmm, it seems like it would be simpler to use a general command line option for a wider, more common use case of not wanting any nulls in output.

@seh
Copy link

seh commented Nov 6, 2015

Alternately:
jq '.foo // empty

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

No branches or pull requests

4 participants