#yq

plaesplaes
2025-12-19

So, in order to do the cleanups, I can use `yq`'s excellent filtering abilities. For example I have a list of verbatim API endpoints like `/token` and `/endpoint/{id}` in `allowed_apis.lst`:

```
yq '(load_str("allowed_apis.lst") | split("\n")) as $l | .paths |= with_entries(select(.key as $k | $l | any_c(. == $k)))' api.yaml > api_cleaned_paths.yaml
```

And similar approach for models, except for `any_c(..)` I have to use `all_c(. != $k)`.

plaesplaes
2025-12-19

So, workflow is following:
0. Manually fix the OpenAPI `bundle.yaml` - this was actually something that caused the tool to exit with error...
1. Filter out unwanted APIs with `yq`
2. Run the openapi-generator-cli validator to get the list of unused models/types
3. Use `sed` to parse the list of unused models/types
4. Use `yq` again to filter out the unneeded models.
5. Generate the "minimum" client and models :)

plaesplaes
2025-12-19

So.. looked into this OpenAPI thing to query an API and eventually found a fancy tool - openapi-generator - openapi-generator.tech/.
With this I can generate a ton of useful boilerplate in almost every programming language.

But what if I only want to communicate only two of the endpoints?!

So, over a few days I've been part-time tinkering with `yq` and `sed` to cut down the autogenerated code to include just the minimum by filtering out the unwanted APIs and data types...

2025-08-11
2024-08-24

que existe "yq", una aplicación para línea de comandos, que permite procesar archivos YAML usando la misma sintaxis que usa "jq", al procesar archivos JSON.

Me está sirviendo para leer configuraciones complejas para scripts en Bash.

mikefarah.gitbook.io/yq

2024-07-07

Programming By Stealth is officially spun off as a standalone podcast with new music, a new intro, and a direct link to @bart’s fabulous tutorial shownotes!

Instalment 169 of X — Advanced YAML Topics pbs.bartificer.net/pbs169

#Programming #ProgrammingByStealth #YAML #yq

Programming By Stealth logo - ninja in squirrely brackets
2024-06-29

🆕 📜: Get webmentions with shell script using jq & yq

Here is my new blog post of how I manage on website to fetch and sync new webmentions, using shell script and `jq` and `yq` to parse and set the data

maw.sh/blog/get-webmention-wit

#pandoc #shell #posix #jq #yq #webmention #indieweb #linux

yqを利用してSAMのテンプレートファイルを分割する
dev.classmethod.jp/articles/sa

#dev_classmethod #AWS_SAM #yq #Bash #AWS #YAML

Schenkl | 🏳️‍🌈🦄schenklklopfer@chaos.social
2024-03-26

Auftrag: ein #YAML parsen.

Aber: ich soll keinen YAML Parser wie #yq verwenden, weil das wird dann zu #kompliziert.

Ich soll also was tun?
Selber einen YAML Parser mit viel grep, sed, awk etc. bauen? Dafür 100 Stunden brauchen und danach etwas haben was noch viel komplizierter ist und beim ersten Sonderzeichen anfängt zu brennen?

-> ich werde yq verwenden.

Tony :fedora: :raspberrypi:s0lution@fosstodon.org
2023-12-28

I'm making a concerted effort to switch flat config files to formatted YAML in my various scripts and utilities. I've been using Mike Farah's yq for my random shell scripts, excellent!
#yaml #developer #shell #yq

elzapp 🐧☁️elzapp@mastodon.cloud
2023-11-14

I'll probably continue to use `yq` for everything Json and Yaml, but I like the interactive mode this one provides: `fx`

#FX - #commandline tool for #JSON
fx.wtf/
#yq

Scott Williams 🐧vwbusguy@mastodon.online
2023-09-11

I half sort of found a way to do this with #Infisical and #yq, by using props annotation and parsing it through yq:

infisical export --env=dev -fyaml | yq -pprops -o yaml

This get it's into properly formatted yaml. yq can also do the same in the opposite direction to import back into infisical.

And to support having .'s in keys, use \\x2e and pass it through echo:

echo -e "$(infisical export --env=dev -fyaml | yq -pprops -o yaml)"

Secrets stored in props style key sytax
2023-09-02

Hello Fediverse, why did nobody tell me about ?

yq: Command-line YAML/XML/TOML processor - jq wrapper for YAML, XML, TOML documents
kislyuk.github.io/yq/

2023-07-30

I got #yq to output #lua tables. Very nice!

2023-07-26

For two days I have been trying to understand how to use Jekyll, a Ruby version of Hugo. It is a Static website generator that is similar to Hugo but rather than being written in Go, it is written in Ruby. I find that it renders sites faster than Hugo, but that it has less assistance for creating pages, giving them layouts and the rest. That’s why I experimented with YQ

a lightweight and portable command-line YAML, JSON and XML processor. YQ uses jq like syntax but works with yaml files as well as json, xml, properties, csv and tsv. It doesn’t yet support everything jq does – but it does support the most common operations and functions, and more is being added continuously.

I read about it in this article. You can install YQ with a brew command brew install yq or you can install it in a number of other ways, depending on whether you’re using MacOS, Linux or Windows.

The Use case

Exporting a WordPress blog to MD files can be done with a multitude of tools but they don’t add all the FrontMatter that you need for a blog, especially Jekyll. I imported the most recent blog posts, that I created for Hugo, with a year-month-date-title.md name to the posts folder but I created a second one for the archive. As the file title was different Jekyll did not like the files. The problem was the file name format, so that’s why I created a separate directory.

Side Note on Reading the Archives MD Files

Bard’s help: I provide this to help you understand Jekyll logic, as well as Bard help.

Getting It To Work On MacOS

In the article about using YQ to edit FrontMatter for Hugo pages the first part worked fine, but it’s written for Linux rather than macOS so some commands failed. This is where Bard comes in.You can ask Bard to explain what parts of a line of code or a command does and it will explain it to you, and you can eventually transfer the command that is understood by one OS and get it to work with the other.

I tried this find -name “*.md” -exec yq –front-matter=”process” ‘.updated_at = now’ {} \; but it failed to work. Bard was kind enough to explain the options for me to figure out which options to use. I added the correct path, and specified that I was looking for the files with the ‘type f’ flag.

find ./_posts -type f -name “*.md” -exec yq ‘.title’ {} \; To see the title of .md files 

I wanted to add these two lines to the FrontMatter of the files in the relevant folder.

I tested find ../unprocessed “*.md” -exec yq –front-matter=”process” ‘.updated_at = now’ {} \; and this works but does not make changes.

This works and updates the pages to add the updated at field to the metadata with the keyword now. The -i tells it to write to the file.

The full command is find ../unprocessed -name “*.md” -exec yq e –front-matter=”process” ‘.updated_at = now’ -i {} \; works to add updated now tag .

Implementing the Required Change

The lines that I wanted to add to the front matter were ‘layout: post’ and ‘categories:

‘. After the trial and error described above I tried:

find ../unprocessed -name “*.md” -exec yq e –front-matter=”process” ‘.updated_at = now’ -i {} \; works to add updated now tag

find ../unprocessed -name “*.md” -exec yq e –front-matter=”process” ‘.layout = post’ -i {} \; works to add updated now tag

Finally the command to make a permanent change was:

find ../_archives -name “*.md” -exec yq e –front-matter=”process” ‘.layout = “post”‘ -i {} \; 

find ../_archives -name “*.md” -exec yq e –front-matter=”process” ‘.categories = “[categories]”‘ -i {} \; 

  • A Quick explanation. The ../archives needs to be replaced with the name of the folder your files are in, when terminal i in the same folder. .layout and .categories are the names of the field to add and the “text” part is the content that you want to add to the front matter.
  • I have unprocessed and archives folders because I tested the code on two files to start with, and when I saw that it worked, then I moved to the main archives folder. I also used git to have a backup of the latest versions. If something had gone wrong I could have “stashed” the mistake, and been back to normal.

The first line ads the layout information to the FrontMatter post and the second one adds the categories information to the posts. Instead of spending hours doing something manually I was able to find the right tools to do what I wanted within seconds.

The Process

I knew what I wanted to do. I started with a google search to see if I could find a tool with some instructions and I did. The instructions were useful, but of limited use for my setup so I used the app’s documentation to try one thing, establishing that this worked, before moving on to accomplish the task that I had set for myself-. Google Bard was able to provide me with some help, but so did chatGPT.

The value of AI tools, in my eyes, is to help us understand the code we’re looking at, but also to help us tweak it for the OS we’re using, when we get error messages. I appreciate that with AI we can ask “I’m getting this error message, why?” and it will help find an answer to the question.

If a web article had provided me with a solution that worked I would have stuck to the web page and I would have little to write about. It is because of trial and error, and using four sources to achieve the goal that I wanted to achieve, that it becomes blog worthy.

#frontmatter #hugo #jekyll #yq

https://www.main-vision.com/richard/blog/yq-frontmatter-and-jekyll/

Watering small trees
2023-05-05

input_filename das ferramentas #jq e #yq não funcionam como esperado: gmgall.net/blog/input_filename

#blog #blogging #json #rss #shell #bash

2023-04-09

Removing nulls from a JSON object with #jq, some notes on same

vielmetti.typepad.com/logbook/

prompted by @fasterthanlime and saved to a blog so that bit of ephemera could be incrementally easier to find.

with a bonus mention of #yq mikefarah.gitbook.io/yq/ which is like jq for YAML, if your life revolves around YAML.

2023-02-27

Whoop whoop - yq is kinda "jq for yaml" :

mikefarah.gitbook.io/yq

Bonus : yq ist able to transform json to yaml and vice versa 🤟

#jq #yaml #transform #yq

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst