zoukankan      html  css  js  c++  java
  • shell 读取yaml 之 shyaml

    安装shyaml
    pip3.7 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.7) localhost:testenv3.7 macname$ cat file.yaml | shyaml get-value idc_group.name
    bx
    (testenv3.7) localhost:testenv3.7 macname$ 
    (testenv3.7) localhost:testenv3.7 macname$ cat file.yaml | shyaml key-values idc_group.bx
    news_bx
    news_bx
    web3_bx
    web3_php-fpm_bx
    (testenv3.7) localhost:testenv3.7 macname$ 

    例子

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

    参考:

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

  • 相关阅读:
    读你必须知道的.NET(二)
    读你必须知道的.NET(四)
    读你必须知道的.NET(三)
    顺序表(线性表)操作的思想及实现之C#版
    HBase原理、基本概念、基本架构3
    HBase学习之深入理解Memstore6
    hadoop学习笔记之hbase完全分布模式安装5
    hbase学习 rowKey的设计4
    WPF开源收集
    请注释你那该死的代码(转载类)
  • 原文地址:https://www.cnblogs.com/sea-stream/p/11983825.html
Copyright © 2011-2022 走看看