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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
35 views

Change value in array using yq from mike farah

In my yaml file I have this persons array (it only has one element always) persons: - name: mario version: 1.0.0 city: Madrid how can I replace city to any other value using yq ?
Andre Silva's user avatar
0 votes
1 answer
79 views

Add content to yaml file using yq from mike farah

This is a basic question but I am struggling to make this work as I have no experience in bash. Lets say I have a directory directory_1 and inside this directory I have cen1.yaml and cen2.yaml. cen1....
Andre Silva's user avatar
-2 votes
3 answers
112 views

sed: -e expression #1, char 101: unterminated `s' command

can someone suggest me what is going wrong here - sed -i "s|##CONNECTION_DETAILS##|${CONNECTION_DETAILS}|g" dep.yaml. The value of CONNECTION_DETAILS is in encoded form: ...
Meenal's user avatar
  • 3
0 votes
1 answer
86 views

bash to get required lines from file using sed/awk [closed]

File content as below: Text1: text_1: Text1 text_1 text_2: - text - file1:\\ - file2:\\ Text2: text_1: Text2 text_1 text_2: - text - file3:\\ Text3: etc Output:...
Rang's's user avatar
  • 11
2 votes
2 answers
422 views

Tool to flatten yaml

Is there a tool to flatten yaml structure like this: foo: bar: baz: true into this: foo.bar.baz = true not sure what is this syntax name context: I need this for hcl, setting a lot of values ...
Kokizzu's user avatar
  • 9,437
0 votes
1 answer
35 views

I encountered an error in the YAML script when using Docker

I am using version: '3.8' services: mydb: image: mysql:5 environment: MYSQL_ROOT_PASSWORD: shiva mywordpress: image: wordpress ports: - 8080:80 links: - mydb: ...
shivasai11's user avatar
0 votes
1 answer
48 views

How to split long commands containing special character into multiline commands?

I have been reading documentation from gitlab at: https://docs.gitlab.com/ee/ci/yaml/script.html#split-long-commands In my case I have a special character (colon ':'), so I also did read: https://...
malat's user avatar
  • 2,830
-1 votes
2 answers
249 views

How do I use yq to change dns severs in a yaml?

Here is my yaml file: network: ethernets: ens160: addresses: - 10.200.2.148/22 gateway4: 10.200.0.1 nameservers: addresses: - 1.1.1.1 - 2.2.2.2 ...
Dave's user avatar
  • 572
2 votes
2 answers
4k views

Bash variable substitution into yq command

Given a YAML file, example.yaml: node: sub_node: get_this: I'd like to get a variable containing get_this using Mike Farah's yq and the string sub_node yaml="$(cat example.yaml)" ...
Lee's user avatar
  • 491
0 votes
1 answer
692 views

Help with yq assignment

I'm trying to use yq to update the static IP on an ubuntu machine via the netcfg yaml file. My file: network: version: 2 renderer: networkd ethernets: enp0s1: dhcp4: no addresses:...
jesse_b's user avatar
  • 36.4k
0 votes
2 answers
212 views

Extract value from broken JSON output in Shell

Once I list the backup files from a server, It throws me the output as follows: { "backupFiles": [ "XYZ_Backup_2.0.0.0-417_2022_08_14_12_10.gz", "...
user560884's user avatar
0 votes
2 answers
3k views

Set and Test Enviornment Variables in .yaml files in Linux

I have one abc.yml file as below which contains username and password parameters. I have stored these parameters in env variable of my linux user But when application is execting abc.yml file it's not ...
Divyank's user avatar
  • 137
0 votes
1 answer
360 views

How can I match file name and a variable in a YAML file?

I am new to shell scripting. What I exactly want to do is this: There is a YAML file and there are different variables in that file, I need to match a particular variable name with a directory name ...
Roger's user avatar
  • 1
2 votes
1 answer
65 views

How to add conditional force to the command in ansible playbook?

I want to copy the file forcedly only for projectA item from below playbook. - name: Populate /usr/local/mywork/ binaries where necessary copy: src: "output/here/usr/local/mywork/{{item}}&...
Hardguy's user avatar
  • 49
4 votes
5 answers
2k views

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: ...
Wyrd by Word's user avatar
-3 votes
2 answers
46 views

am not sure how to write on other file

hi i have this script called script.sh have 2 variable #! /bin/bash read -p " name " name read -p " last " last ( here am not sure what to do but if possible to open file name....
Mohamed Khalil Rouissi's user avatar
0 votes
0 answers
36 views

Match only first number from exact 'word' and ignore if fail [duplicate]

Currently I have written this to extract numbers from PASS_MAX_DAYS [number]. I want it to ignore if it matches the example. Example(only bold numbers) PASS_MAX_DAYS 30 pass_max_days 30 PASS_MAX_DAYS ...
JakePaul's user avatar
1 vote
1 answer
982 views

regexp to only extract first set/group of numbers from line of string from a file

How can I use regexp to extract first set/group of numbers from line of string from a file and ignore lines that have two set of numbers, any symbol (except PASS_MAX_DAYS), and have it show on the ...
JakePaul's user avatar
0 votes
2 answers
1k views

bash iterate through several directories to build one single yaml file

I have a directory with several folders (only interested in folders one level deep) and each one of these folders have files inside (values.yaml and example.yaml) folder_1 -values.yaml -example.yaml ...
Andre Silva's user avatar
1 vote
4 answers
3k views

Using Bash to iterate through nested directories and extract certain fields from YAML files

I am learning bash and what I need is to iterate through a directory (inside has other directories) and find all files with the name example.yaml. These files have several key-value pairs (example ...
Andre Silva's user avatar
0 votes
4 answers
365 views

sed vs. awk: Read a file line by line and append to a specific line in another file

Consider two files below users.txt: Arnold.Bosch David.Ledru Mehri.Sunny and docker-compose.txt: version: '3.9' services: strongswan-server: image: vpn-strongswan container_name: strongswan-...
sci9's user avatar
  • 517
0 votes
3 answers
57 views

Determine IP address and edit the config in single command

I'm trying to determine internal IP of a docker container and use that as an value in an yaml config file. The command for determining the IP is; docker inspect -f '{{range.NetworkSettings.Networks}}{{...
Mridul Gain's user avatar
0 votes
1 answer
108 views

Need help Formatting a file having key: value [duplicate]

I have a file having the below values: cat data.txt server1: 'calv' server2: 'anot' log: '/u/log/1' server3: 'calv' server4: 'anot' server5: 'secd' server6: 'calv' LIB_TRGT_calv,anot: '/tmp/hello.txt' ...
Ashar's user avatar
  • 469
3 votes
1 answer
2k views

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 ...
Paul Maxfield's user avatar
0 votes
1 answer
146 views

Convert puppet manifest config to hiera

I installed corosync-pacemaker cluster via puppet. Now I would to like keep my data into hiera file. How should I convert cs_primitive section into yaml file? cs_primitive { 'nfsshare_fs': ...
fortunate1357's user avatar
3 votes
5 answers
736 views

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' ...
Ashar's user avatar
  • 469
3 votes
2 answers
1k views

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: ...
Jackson's user avatar
  • 215
0 votes
2 answers
557 views

sed command to replace pattern including newline pattern with blank

I have a yaml file which include text: - name: flexvol-driver-host hostPath: type: DirectoryOrCreate path: /usr/libexec/kubernetes/kubelet-plugins/volume/exec ...
Thor's user avatar
  • 113
1 vote
1 answer
498 views

Parsing YAML to create dynamic queries in shell

I am very new to scripting, and I have been tasked with figuring out a way to script a shell script that will create SQL queries based on a provided YAML document. I could trace down the yq parser to ...
Akash's user avatar
  • 111
-1 votes
1 answer
187 views

How to replace a pattern permanently in a file using pipe Unix command

I have following lines, so I just want to replace particularly client_encryption_options: enabled: true to client_encryption_options: enabled: false ...
manoj's user avatar
  • 107
1 vote
3 answers
2k views

Generate templates in yaml from a CSV file

I am trying to create yaml files from a template using my variables. My yaml template look like this number: {{NUMBER}} name: {{NAME}} region: {{REGION}} storenum: {{STORENUM}} clients: {{...
Jo0l's user avatar
  • 11
-1 votes
1 answer
50 views

File Comparison

I have two files with FILE1 containing lots of lines and FILE2 with KEY VALUE parms. I need to compare FILE2 with FILE1 and if there is match the corresponding word in FILE1 should be replace with ...
Ram's user avatar
  • 335
1 vote
1 answer
1k views

Generate full paths from nested (for example yaml) directory structure

I try to write script in shell/bash that will convert yaml directory structure to full paths (for further mkdir -p it). Yaml is my choice because of human-editability. Structure example is: - ...
Masaki Maeda's user avatar
0 votes
3 answers
6k views

Shell script to find the list of a keys inside a key in Yaml file

I have a yaml file info: description: Api contact: name: Api tags: - name: "" description: "" paths: /data1/1: post: tags: - "tag1" /...
Prashanth Sams's user avatar
2 votes
2 answers
8k views

Modify yaml file in bash without any external dependency

I've multiple configurations in YAML file and I need to change some paramaters using a Bash script. Is it possible? I want to avoid using any external dependency. My YAML Looks like %YAML 1.2 --- name:...
Pranjal Doshi's user avatar
-1 votes
2 answers
284 views

Append new webhook to alertmanager config file using shell

I am using alertmanager for notification purpose and by default alertmanager only has one webhook. As per my requirement one more webhook is required. Existing config global: resolve_timeout: 5m ...
Viney Dhiman's user avatar
0 votes
0 answers
122 views

Can't fold YAML block in Vim after commenting it out

I have a YAML file, and configured the folding of different sections for the document in the Vim editor. However, when I comment out a section, it remains unfolded, and trying to "re-fold" ...
keithRozario's user avatar
0 votes
1 answer
1k views

Ansible facts output in one line

I need some information from Ansible facts, hence created below YAML. but its giving error. My requirement is to get the output in one line. So that we can filter it using CSV or spreadsheet. --- - ...
AReddy's user avatar
  • 3,152
0 votes
1 answer
755 views

Is it possible to make a YAML use ISO 8601 date format?

I am using a tool called organize in order to sort folders with a lot of stuff in them and was wondering if it was possible to tell it to create, sort, or rename using ISO 8601 date format. The config ...
telometto's user avatar
  • 1,875
6 votes
4 answers
8k views

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 ...
Dave's user avatar
  • 2,448
0 votes
3 answers
3k views

Struggling using sed command with variables

So I have the following variables defined in a bash script: new_commit="back:h3912kk" old_commit="back:1.0.1" file = docker-compose.yml Then I have this yml $file: version: '...
JamesHudson81's user avatar
3 votes
6 answers
1k views

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 ...
user3674993's user avatar
0 votes
4 answers
2k views

How do I get a multiline awk script running in bash

To start this script is running it a Github workflow, using shell bash, yaml truncated for readability. I've tried a number of things to make it work as multiline, so I can have comments. set -x ...
xenoterracide's user avatar
1 vote
2 answers
999 views

Using sed to match a dynamic, multi-line string and append to it

I have an Ansible yaml file that I want to append on a new line after state: present in the example matches below with use: package_manager using sed. # Example 1 - name: Package X Install package: ...
deaugur's user avatar
  • 11
6 votes
5 answers
2k views

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 ...
siraj's user avatar
  • 185
0 votes
3 answers
2k views

Parse yaml file without using outside tool [duplicate]

I am new to bash, dragged into a problem where I need to update some dynamic parameters in a yaml file Based on query (search4.subsearch1.name), i need to update name: old_name into name: new_name ...
g_jha's user avatar
  • 19
-2 votes
1 answer
741 views

Is JSON and YAML considered Markup languages? [closed]

I have my Comp Tia Linux+ (XK0-004) exam tomorrow. I purchased the "Compt Tia Linux+ All in one Exam Guide) book off Amazon and this book is contradicting what Google searches are saying ...
TClapStorm's user avatar
1 vote
1 answer
4k views

Ansible: Could not locate file in lookup

I wrote a playbook to deploy my ssh keys across multiple instances. This my playbook, but I am experiencing some problems with it. I already created my ssh keys from my local instance. Please see ...
hxugox97's user avatar
0 votes
2 answers
1k views

grep in limiting

I have a YAML file: - name: scheduler-configuration - name: scheduler I'm grepping some thing like grep "scheduler" file.txt The output it is showing both lines, but I want only single ...
yugandhar's user avatar
0 votes
3 answers
11k views

SED replace in next line in yaml

I am trying to replace the tag value but having no luck with sed Here is the file looks like and i would like to replace the tag value uniquely app1: tag: "dev-0.114" repository: kafka ...
Sabareesh Kkanan's user avatar