Manpage logo

yx - extract data from a YAML file


YX(1) General Commands Manual YX(1)

NAME

yx — extract data from a YAML file

SYNOPSIS

yx [−hv] [−d n] [−f file] [

key | index ] ...

DESCRIPTION

yx parses a YAML file and prints the value selected by the path specified by the list of key and index arguments.

−d n, −−doc n

Use n’th YAML document. By default the first YAML document is used.

−f file, −−file file

Read YAML input from file. By default standard input is used. Standard input can also be explicitly requested with file specified as ‘−’.

−h, −−help

Print usage and exit.

−v, −−version

Print program version and exit.

A path componet is either a key or an index. A key selects from a mapping. An index (1-based) selects from a sequence.

If the path selects a scalar value, the value is printed on the standard output.

If the path you specify selects a mapping, yx prints the keys of that mapping one per line.

$ 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.

$ cat seq.yaml
[one, two, three]
$ yx -f seq.yaml
1
2
3

HISTORY

yx was written as a helper utility for tiny-cloud to parse user-data from shell scripts.

AUTHORS

Jake Buchholz Göktürk <[email protected]> GNU January 20, 2024 YX(1)


Updated 2026-06-01 - jenkler.se | uex.se