Bash-YAML is a simple YAML parser written in Bash script.
MIT License
Bash-YAML is a simple YAML parser.
git clone https://github.com/ArtBIT/bash-yaml.git
source path/to/bash-yaml/src/yaml
clam install ArtBIT/bash-yaml --source src/yaml
# (Contents of example1.yml)
# | some:
# | deeply:
# | nested:
# | option: 1
#
cat example1.yml | yaml_get_value some.deeply.nested.option
# Outputs 1
# (Contents of example2.yml)
# | app:
# | settings:
# | title: My Awesome App
# | color: #DADADA
# | language: en
#
eval "$(cat example2.yml | yaml_parse app.settings)"
# Defines the following bash variables
# app_settings=""
# app_settings_title="My Awesome App"
# app_settings_color="#DADADA"
# app_settings_language="en"
eval "$(cat example.yml | yaml_parse app.settings --prefix noconflict)"
# Defines the following bash variables
# noconflict_app_settings=""
# noconflict_app_settings_title="My Awesome App"
# noconflict_app_settings_color="#DADADA"
# noconflict_app_settings_language="en"
# (Contents of example3.yml)
# | app:
# | settings:
# | title: My Awesome App
# | color: #DADADA
# | language: en
#
cat example3.yml |
yaml_replace app.settings.color "#FFF" |
yaml_replace app.settings.language "rs" |
yaml_replace app.settings.title "My Other App"
# Will output:
app:
settings:
title: My Other App
color: #FFF
language: rs
# The source file is not automatically updated, if you
# want to update the original filename, please use
# `sponge` to wait for the stdin to dry-out
# before writing to original file, to avoid race conditions.
cat example3.yml |
yaml_replace app.settings.color "#FFF" |
yaml_replace app.settings.language "rs" |
yaml_replace app.settings.title "My Other App" |
sponge example3.yml