This commit is contained in:
Mike Farah 2022-04-15 08:52:46 +10:00
parent 91ac643fbf
commit 3fe9e55f36
3 changed files with 14 additions and 3 deletions

View File

@ -135,7 +135,9 @@ a:
b: b:
- dog - dog
- mouse - mouse
a3: {b: [mouse]} a3:
b:
- mouse
``` ```
## String concatenation ## String concatenation

View File

@ -199,7 +199,8 @@ yq '.a.b |= "bogs"' sample.yml
``` ```
will output will output
```yaml ```yaml
{a: {b: bogs}} a:
b: bogs
``` ```
## Update node value that has an anchor ## Update node value that has an anchor
@ -229,6 +230,8 @@ yq '.a.b.[0] |= "bogs"' sample.yml
``` ```
will output will output
```yaml ```yaml
{a: {b: [bogs]}} a:
b:
- bogs
``` ```

View File

@ -2,6 +2,12 @@
`yq` can process files with `yaml` front matter (e.g. jekyll, assemble and others) - this is done via the `--front-matter/-f` flag. `yq` can process files with `yaml` front matter (e.g. jekyll, assemble and others) - this is done via the `--front-matter/-f` flag.
Note that `yq` only processes the first passed in file for front-matter. If you'd like to process multiple files, you can:
```bash
find -name "*.md" -exec yq --front-matter="process" '.updated_at = now' {} \;
```
## Process front matter ## Process front matter
Use `--front-matter=process` to process the front matter, that is run the expression against the `yaml` content, and output back the entire file, included the non-yaml content block. For example: Use `--front-matter=process` to process the front matter, that is run the expression against the `yaml` content, and output back the entire file, included the non-yaml content block. For example: