Skip to content

Instantly share code, notes, and snippets.

@rsperl
Last active July 25, 2022 12:49
Show Gist options
  • Select an option

  • Save rsperl/98514bb07e37635f4522795d6f484725 to your computer and use it in GitHub Desktop.

Select an option

Save rsperl/98514bb07e37635f4522795d6f484725 to your computer and use it in GitHub Desktop.
Use jq to remove keys based on regex #snippet

Remove all entries that have a key ending in .comment:

echo '{"key": "value", "key.comment": "key comment"}'  | \
	jq '.|with_entries(select(.key|test(".\\.comment$")|not))'

gives

{
  "key": "value"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment