shell 读取yaml 之 shyaml
安装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的更多相关文章
- Python读取Yaml文件
近期看到好多使用Yaml文件做为配置文件或者数据文件的工程,随即也研究了下,发现Yaml有几个优点:可读性好.和脚本语言的交互性好(确实非常好).使用实现语言的数据类型.有一个一致的数据模型.易于实现 ...
- Shell读取配置文件的方法
参考:http://www.cnblogs.com/binbinjx/p/5680214.html 做批量软件安装自动化时,都喜欢用配置文件的方式改变参数,那怎么通过shell读取配置文件的配置呢?参 ...
- python的logging模块之读取yaml配置文件。
python的logging模块是用来记录应用程序的日志的.关于logging模块的介绍,我这里不赘述,请参见其他资料.这里主要讲讲如何来读取yaml配置文件进行定制化的日志输出. python要读取 ...
- shell读取文件内容并进行变量赋值
需求: shell读取文件内容,然后把内容赋值给变量然后进行字符串处理 实现: dataline=$(cat /root/data/data.txt) echo $dataline
- Golang 入门系列(九) 如何读取YAML,JSON,INI等配置文件
实际项目中,读取相关的系统配置文件是很常见的事情.今天就来说一说,Golang 是如何读取YAML,JSON,INI等配置文件的. 1. json使用 JSON 应该比较熟悉,它是一种轻量级的数据交换 ...
- 使用python读取yaml文件
在做APP测试时,通常需要把参数存到一个字典变量中,这时可以将参数写入yaml文件中,再读取出来. 新建yaml文件(android_caps.yaml),文件内容为: platformName: A ...
- shell读取文件的每一行内容并输出【转】
写法一: #!/bin/bash while read line do echo $line done < file(待读取的文件) 写法二: #!/bin/bash cat file(待读取的 ...
- 登录shell与非登录shell读取文件过程
登录shell与非登录shell读取文件过程登录:/etc/profile→/etc/profile.d/*.sh ~/.bash_profile非登录:~/.bash_profile→ ...
- java 读取 yaml 文件
做 java 项目用的最多的配置文件就是 properites 或者 xml, xml 确实是被用烂了,Struts, Spring, Hibernate(ssh) 无一不用到 xml.相比厚 ...
随机推荐
- V2Ray+WebSocket+TLS+Nginx 配置及使用
v2ray 是一个模块化的代理工具,支持 VMess,Socks,HTTP,Shadowsocks 等等协议,并且附带很多高级功能,HTTP,TLS 等等. 关键词限制,全文 v2ray 中的 y 为 ...
- Windows Server 2008 R2 install Visual Studio 2015 failed
Please download and install Windows Server 2008 R2 Service Pack 1 (KB976932) . https://www.microsoft ...
- 基于直接缓冲区和非直接缓冲区的javaIO文件操作
基本概念: 1. 非直接缓冲区: 指的是通过jvm来缓存数据的,应用程序要读取本地数据要经历从本地磁盘到物理内存,然后copy到jvm中,然后再通过流的方式读取到应用程序中,写的操作正好与之相反. ...
- 百度站长平台HTTPS认证所遇到的坑
坑1: 百度站长平台https认证失败,提示:请确保您网站的所有链接均支持https访问,且未使用不安全协议(如:SSL2.SSL3等协议). 解决办法: 1. 友情链接检查, 要检查所有的友情链接 ...
- C# 实现敏感词过滤
实现 该 敏感词过滤 采用的是 DFA算法,参考文章:https://blog.csdn.net/chenssy/article/details/26961957 具体 实现 步骤 如下: 第一步,构 ...
- U盘安装CentOS 7提示 “Warning: /dev/root does not exist, could not boot” 解决办法
1.把U盘的Lable(即标签)修改成centos 2.在安装界面上按TAB键,修改启动路径,把”CENTOS\x207\x20x86_64″改成 “centos”
- 纯C语言实现顺序队列
#include <stdio.h> #include <stdlib.h> #define MAXSIZE 6 typedef int QElemType; typedef ...
- Vue实战狗尾草博客管理系统第一章
Vue实战狗尾草博客后台管理系统第一章 这里准备采用的技术栈为:vue全家桶+element-ui 这里因为是后台管理系统,没有做SSR的必要.所以这里就采用前后端分离来昨晚这个项目~ 项目搭建 vu ...
- 【分布式搜索引擎】Elasticsearch之安装Elasticsearch可视化平台Kibana
一.Kibana简单介绍 Kibana 是为 Elasticsearch设计的开源分析和可视化平台.你可以使用 Kibana 来搜索,查看存储在 Elasticsearch 索引中的数据并与之交互.你 ...
- Linux 初识Libevent网络库
初识Libevent libevent是用c写的高并发网络io库,只要有文件描述符,就都可使用libevent. libevent使用回调函数(callback) . 有了libevent,网络编程我 ...