安装shyaml
pip3. install shyaml

file.yaml文件内容
---
idc_group:
name: bx
bx:
news_bx: news_bx
web3_bx: web3_php-fpm_bx
task: [1,2,3,4,5,6]


(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml get-value idc_group.name
bx
(testenv3.) localhost:testenv3. macname$
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml key-values idc_group.bx
news_bx
news_bx
web3_bx
web3_php-fpm_bx
(testenv3.) localhost:testenv3. macname$

例子

get-value:获取值
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml get-value idc_group.bx.news_bx
news_bx
(testenv3.) localhost:testenv3. macname$ get-type:获取相应的类型
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml get-type idc_group.bx.news_bx
str
(testenv3.) localhost:testenv3. macname$ get-values{,-}:对序列类型来说,获取值列表
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml get-values idc_group.bx.task (testenv3.) localhost:testenv3. macname$ keys{,-}:返回键列表
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml keys idc_group
name
bx
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml keys idc_group.bx
news_bx
web3_bx
task
(testenv3.) localhost:testenv3. macname$ values{,-}:返回值列表
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml values idc_group.bx
news_bx
web3_php-fpm_bx
-
-
-
-
-
-
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml values idc_group
bx
news_bx: news_bx
web3_bx: web3_php-fpm_bx
task:
-
-
-
-
-
-
(testenv3.) localhost:testenv3. macname$ key-values,{,-}:返回键值对
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml key-values idc_group.bx
news_bx
news_bx
web3_bx
web3_php-fpm_bx
task
-
-
-
-
-
-
(testenv3.) localhost:testenv3. macname$ cat file.yaml | shyaml key-values idc_group
name
bx
bx
news_bx: news_bx
web3_bx: web3_php-fpm_bx
task:
-
-
-
-
-
-
(testenv3.) localhost:testenv3. macname$

参考:

https://www.linuxidc.com/Linux/2016-04/130403.htm

shell 读取yaml 之 shyaml的更多相关文章

  1. Python读取Yaml文件

    近期看到好多使用Yaml文件做为配置文件或者数据文件的工程,随即也研究了下,发现Yaml有几个优点:可读性好.和脚本语言的交互性好(确实非常好).使用实现语言的数据类型.有一个一致的数据模型.易于实现 ...

  2. Shell读取配置文件的方法

    参考:http://www.cnblogs.com/binbinjx/p/5680214.html 做批量软件安装自动化时,都喜欢用配置文件的方式改变参数,那怎么通过shell读取配置文件的配置呢?参 ...

  3. python的logging模块之读取yaml配置文件。

    python的logging模块是用来记录应用程序的日志的.关于logging模块的介绍,我这里不赘述,请参见其他资料.这里主要讲讲如何来读取yaml配置文件进行定制化的日志输出. python要读取 ...

  4. shell读取文件内容并进行变量赋值

    需求: shell读取文件内容,然后把内容赋值给变量然后进行字符串处理 实现: dataline=$(cat /root/data/data.txt) echo $dataline

  5. Golang 入门系列(九) 如何读取YAML,JSON,INI等配置文件

    实际项目中,读取相关的系统配置文件是很常见的事情.今天就来说一说,Golang 是如何读取YAML,JSON,INI等配置文件的. 1. json使用 JSON 应该比较熟悉,它是一种轻量级的数据交换 ...

  6. 使用python读取yaml文件

    在做APP测试时,通常需要把参数存到一个字典变量中,这时可以将参数写入yaml文件中,再读取出来. 新建yaml文件(android_caps.yaml),文件内容为: platformName: A ...

  7. shell读取文件的每一行内容并输出【转】

    写法一: #!/bin/bash while read line do echo $line done < file(待读取的文件) 写法二: #!/bin/bash cat file(待读取的 ...

  8. 登录shell与非登录shell读取文件过程

    登录shell与非登录shell读取文件过程登录:/etc/profile→/etc/profile.d/*.sh        ~/.bash_profile非登录:~/.bash_profile→ ...

  9. java 读取 yaml 文件

        做 java 项目用的最多的配置文件就是 properites 或者 xml, xml 确实是被用烂了,Struts, Spring, Hibernate(ssh) 无一不用到 xml.相比厚 ...

随机推荐

  1. SAP PI开发手册-ERP发布服务供外部系统调用(sproxy代理类)

    转自:https://www.cnblogs.com/fanjb/p/10829858.html 一.      接口内容 接口详细信息 1.  字段对应关系 发送字段对应关系 返回字段对应关系 2. ...

  2. CSS3 transform 属性(2D,3D旋转)

    一.语法 div{ transform:rotate(7deg); -ms-transform:rotate(7deg); /* IE 9 */ -moz-transform:rotate(7deg) ...

  3. 工作笔记--Python自动切换host

    修改host代码: #coding:utf-8import os,time pwd = os.path.dirname(__file__) #获取当前文件夹的绝对路径pull_host_cmd = ' ...

  4. 遍历倒排索引核心类:SegmentTermDocs/SegmentTermPositions

    查询有哪些文档包含某个词元是Lucene搜索非常基础的一个功能,上层的搜索功能和索引功能都要基于这个功能来搭建.SegmentTermDocs就是查询词元所属文档的核心类,SegmentTermPos ...

  5. GSOAP服务卡住?

    很久以前参考了https://www.genivia.com/doc/soapdoc2.html 中的一段: How to Create a Multi-Threaded Stand-Alone Se ...

  6. 【推荐】全球最全面的Telegram组群频道的集合网站 持续收集中

    全球最全面的Telegram组群频道的集合网站 https://www.telegramgroup.org Telegram 组群频道分享 可搜索自己想找的组群频道 从小白到大神,一个 telegra ...

  7. 模块 time,datetime,random,typing,hashlib,requests,re

    目录 包 什么是包 为什么要包 1. 包的介绍 2. 绝对导入和相对导入 - 绝对导入 - 相对导入 time模块 时间戳 格式化时间 结构化时间 sleep datetime模块 random模块 ...

  8. 使用 PXE+Kickstart 实现无人值守批量部署系统

    一.废话两句 在云数据中心,一次几十台甚至几百台服务器上线,系统安装将变得非常繁琐,系统安装好了后还会涉及很多配置,如果一台台来安装的话工作量非常大.(虽然有加班费,开个玩笑)为了解决这个问题,我们需 ...

  9. jersey实现RESTful接口PUT方法JSON数据传递

    项目中使用的是org.json包 maven中的配置如下: xml <!-- https://mvnrepository.com/artifact/org.json/json --> &l ...

  10. MATLAB之指定文件读取与读取地址输出

    一.读取指定文件夹下的指定格式文件 (1) 利用命令 uigetdir('','') 参数解释: uigetdir('所要打开的盘地址','对打开的弹出框进行描述') 例如:uigetdir('C:\ ...