Questions tagged [yaml]

YAML is a data serialisation format designed for human readability, supporting data with self references. YAML 1.2 is a superset of JSON, so its tools can be used to process JSON. Use this tag for question that involve features specific to the YAML format.

YAML is a human readable data serialisation format. Its readability make it a popular choice for configuration files that have no special tools for editing.

YAML is currently at revision 1.2 (from 2009) although care must be taken that some parsers still only support version 1.1 or default to supporting its deprecated features ( octals not requiring Oo, sexagesimals, Yes/No/On/Off as booleans).

Commandline tools that can handle YAML:

  • yaml (installable by pip install ruamel.yaml.cmd
82 questions
18
votes
7 answers

Is it possible to modify a yml file via shell script?

This is how my docker-compose.yml looks like. nginx: container_name: 'nginx' image: 'nginx:1.11' restart: 'always' ports: - '80:80' - '443:443' volumes: - '/opt/nginx/conf.d:/etc/nginx/conf.d:ro' links: - 'anything' Now…
user3142695
  • 1,529
  • 7
  • 20
  • 34
6
votes
4 answers

How do I remove all specific sub-sections of a specific header in a YAML file?

I'm using bash shell. I have a YAML file from which I want to remove certain blocks of text. /image-content: post: operationId: createEventPublic summary: Process events description: Process events parameters: [] …
Dave
  • 2,348
  • 21
  • 54
  • 84
6
votes
5 answers

Replace value in "key: value" statement, but only on first occurence of the key in the file

I have a yml file spring: datasource: url: url username:test password: testpwd api: security: username:foo password: foopwd I want to update only the first occurrence or username and password using the command line on a…
siraj
  • 185
  • 1
  • 8
4
votes
5 answers

How to use awk to extract a YAML metadata block

I have many Markdown files with a YAML metadata block at the top: --- title: title of work author: author name author-sort: name, author published: N date: XXXX-XX-XX pub-number: XXXXX embedded-title: false --- **title** a piece of indertimate …
4
votes
2 answers

Tool for manipulating YAML files?

We want to implement a workflow that includes having YAML configuration files where we wish to change some of the contents before actually using them, and we are looking for a good command line tool to do this. This can be as simple as setting a…
3
votes
4 answers

Tab-delimited values to YAML conversion

I have a file with tab-delimited values in this format: your-email your-order-id PayPal-transaction-id your-first-name your-second-name [email protected] 12345 54321 sooky spooky [email protected] 23456 23456 kiki dee [email protected] 34567 76543…
duff
  • 133
  • 1
  • 3
3
votes
1 answer

ignore whitespace at the beginning of a search pattern

This sed expression works, but is there a better way to represent the white space in both the search pattern and replace string? BRANCHTAG=7.17.9-main-5ee3e99d5ff002862d93728d821461033de1186d PRIOR_VERSION=7.17.4 clear; sed "s/^ newTag:…
3
votes
5 answers

find duplicate 1st field and concat its values in single line

I have a file that has entries in key: value format like the below: cat data.txt name: 'tom' tom_age: '31' status_tom_mar: 'yes' school: 'anne' fd_year_anne: '1987' name: 'hmz' hmz_age: '21' status_hmz_mar: 'no' school: 'svp' fd_year_svp:…
Ashar
  • 449
  • 3
  • 10
  • 26
3
votes
2 answers

How to extract a few IP addresses from a YAML file

I have this file, and I'd like to select all the IP addresses under the masters/hosts section if their line is not commented. I tried this sed 's/.*\ \([0-9\.]\+\).*/\1/g', but it did not work. metal: children: masters: hosts: …
Jackson
  • 215
  • 1
  • 2
  • 7
3
votes
6 answers

Passing variable to AWK not working inside a loop

I have this awk statement that reads a YAML file and outputs a particular value. I need to loop this awk inside a loop where I read a key value from a list of values and pass that key to awk. The YAML file has this structure: abc: NAME: Bob …
3
votes
3 answers

Parse a YAML section using shell

I have a YAML that looks like something: - whatever: - something - toc: 4 - body: assets/footer.html pkg: - pkg_a_1: - Shass - AJh55 - ASH7 - pkg_b_1: - Kjs6 - opsaa other: morestuff: - whatever I would like to pull out…
mindlessgreen
  • 1,229
  • 4
  • 12
  • 21
3
votes
4 answers

Filter YAML file content using sed/awk

I have a text file with the following content in it. $ cat hosts.yml [prod_env] foo.example.com bar.example.com [stage_env] foo_stage.example.com bar_stage.example.com [dev_env] foo_dev1.example.com dev2_bar.example.com I would like to filter hosts…
smc
  • 561
  • 3
  • 10
  • 24
3
votes
2 answers

Finding incorrect YAML headers

I am trying to identify which files in my project have incorrect headers. The files all starts like this --- header: . . . title: some header: . . . more headers: level: . . . --- Where . . . only represents more headers. The headers contains no…
3
votes
3 answers

Replace all occurrences of dash to the left of a colon using sed

I have the following values in a config.yml file: scratch-org-def: config/project-scratch-def.json assign-permset: false permset-name: run-apex-tests: true apex-test-format: tap delete-scratch-org: false show-scratch-org-url: true I need to…
Wade
  • 133
  • 1
  • 3
3
votes
2 answers

How to merge these commands into one?

This is what I am wanting to do: Convert a folder of HTML files into markdown, also copying over the the XML metadata of each of the HTML files by converting into YAML. I have done research and came across the following commands: find . -name \*.md…
1
2 3 4 5 6