安装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. Freemarker入门Demo

    1:工程引入依赖 <dependency> <groupId>org.freemarker</groupId> <artifactId>freemark ...

  2. vue中toggle切换的3种写法

    前言:查看下面代码,在任意编辑器中直接复制粘贴运行即可 1:非动态组件(全局注册2个组件,借用v-if指令和三元表达式) <!DOCTYPE html> <html> < ...

  3. 1.go语言入门

    1.Go语言中文网,选择相应版本(32位或64位)下载 https://studygolang.com/dl, 2.解压到一个任意文件夹 3.配置环境变量 cmd命令行输入go version查看当前 ...

  4. 在 EF Core 中 Book 实体在新增、修改、删除时,给 LastUpdated 字段赋值。

    直接贴代码: public class MenusContext : DbContext { public static class ColumnNames { public const string ...

  5. Window权限维持(六):BITS Jobs

    Windows操作系统包含各种实用程序,系统管理员可以使用它们来执行各种任务.这些实用程序之一是后台智能传输服务(BITS),它可以促进文件到Web服务器(HTTP)和共享文件夹(SMB)的传输能力. ...

  6. Python 学习 第15篇:日期和时间

    datetime模块中包含五种基本类型:date.time.datetime.timedelta和tzinfo,tz是time zone的缩写,tzinfo用于表示时区信息. 一,date类型 dat ...

  7. C# 随机 抽奖 50个随机码 不重复

    static List<int> Given50RandomNumbers() { List<int> intList = new List<int>(); for ...

  8. P5124 Teamwork(DP)

    题目: P5124 [USACO18DEC]Teamwork 解析: 动态规划,设\(f[i]\)表示到第\(i\)位的最大值,我们枚举i之前的j个位置\((j<k)\),记录一下这\(j+1\ ...

  9. 解决 bash: vue command not found

    背景  : win10 使用  yarn  全局 安装  vue/cli 后   yarn  global add  @vue/cli 提示安装成功 使用vue create   提示  bash: ...

  10. 实施一套MES系统需要多少钱?

    在制造业深耕的人都知道MES系统对于企业的重要性.MES生产执行系统是制造业生产现场透明化管理的最佳解决方案,制造业工厂通过实施MES系统可以解决生产计划.排产调度.工艺管理.品质管理.现场数据采集和 ...