Skip to content

Instantly share code, notes, and snippets.

@david-mart
Last active September 11, 2023 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-mart/37ff11102739c5ac3e0da455eb34f4bc to your computer and use it in GitHub Desktop.
Save david-mart/37ff11102739c5ac3e0da455eb34f4bc to your computer and use it in GitHub Desktop.

YQ Recipies

Unnest dot-separated keys object

yq -p=json -o=json -i=0 junk/model.jsonl | 
yq -p=json -o=json -i=0 '(
    .output_text 
  | from_json 
  | . as $x 
  | keys 
  | .[] as $item ireduce ({}; setpath($item | split("."); $x[$item]))
)'

Wildcard delete packages from package.json

cat package.json| yq '.devDependencies | keys | .[] | select(. == "*mdx*")' | xargs yarn remove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment