Jobin0528
V2EX  ›  Bash

[求助] shell 处理 yaml

  •  
  •   Jobin0528 · Dec 9, 2018 via iPhone · 10028 views
    This topic created in 2739 days ago, the information mentioned may be changed or developed.
    想用 shell 处理 clash 的 yaml 配置文件,找到了工具 shyaml,但还是不知道怎么提取出 name 中包含某关键字的节点,像这样搜到某个关键字,输出整个数组不对行处理输出的,不知道怎么弄了。
    Supplement 1  ·  Dec 10, 2018
    目前采用了个临时解决方案:用 grep 匹配关键字后向下取固定行数,也能暂时解决问题。
    但是如果源文件更改了每个数组的行数,我不知道的情况下,就会取错。
    所以最好的解决方案还是匹配某个数组的关键字,输出整个数组。
    2 replies    2018-12-10 01:01:35 +08:00
    arslan2012
        1
    arslan2012  
       Dec 10, 2018 via iPhone
    我们一般在 shell 中遇到要进行 yaml 操作时,直接就 ruby -e 了
    SoloCompany
        2
    SoloCompany  
       Dec 10, 2018 via iPad
    brew install yaml2json
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1694 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 16:30 · PVG 00:30 · LAX 09:30 · JFK 12:30
    ♥ Do have faith in what you're doing.