YX(1)
π yx(1) β the girlies' guide to pulling data out of YAML
okay so first things first: this is the manual page for yx, and it lives in section 1 of the General Commands Manual (that's the (1) bestie, that's what it means π). It's a little command-line icon and she's here to help.
β¨ SYNOPSIS β¨
yx [-hv] [-d n] [-f file] [key | index] ...
πΈ DESCRIPTION πΈ
yx parses a YAML file and prints out the value that's selected by the path you give it β and that path is literally just the list of key and index arguments you tack on. That's it. That's the whole vibe check. π¦
-d n,--doc nβ use the n'th YAML document, bestie. By default the first YAML document is the one that gets used. π-f file,--file fileβ read the YAML input from file. By default, standard input is used. Standard input can also be explicitly requested by specifying file as'-'(yes, literally just a dash, she's iconic like that). ποΈ-h,--helpβ print usage and exit. classic. π«-v,--versionβ print program version and exit. also classic. π«
now for the actual path mechanics, and ngl this part is the main character energy of the whole page:
A path component is either a key or an index. A key selects from a mapping. An index (1-based, so like, the first one is 1, not 0, we're not doing that here) selects from a sequence. π
If the path selects a scalar value, that value gets printed on the standard output. simple, clean, ate. β¨
If the path you specify selects a mapping, yx prints the keys of that mapping, one per line. like so:
$ cat map.yaml
foo: one
bar: two
blah: argh
$ yx -f map.yaml
foo
bar
blah
If the path you specify selects a sequence, yx prints the list of valid indices, one per line. like so:
$ cat seq.yaml
[one, two, three]
$ yx -f seq.yaml
1
2
3
see? valid indices. one per line. gorgeous. π
π¦ HISTORY π¦
yx was written as a helper utility for tiny-cloud, to parse user-data from shell scripts. so basically she started out as a little behind-the-scenes bestie and now she has her own manpage. glow up fr fr. π
π«Ά AUTHORS π«Ά
Jake Buchholz GΓΆktΓΌrk <tomalok@gmail.com>
π and that's the whole page, bestie! no cap, you're now a yx expert.
sign-off time: this one came from Debian, dated January 20, 2024. mwah, go forth and parse ππ§ββοΈ
π¦ where this page comes from
- alpine 3.22: yx-doc 1.0.2-r0 Β· MIT
- alpine 3.23: yx-doc 1.0.2-r0 Β· MIT
- alpine 3.24: yx-doc 1.0.2-r0 Β· MIT
- nixos 26.05: yx 1.0.2
- nixpkgs unstable: yx 1.0.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms