yuedingwangji
V2EX  ›  问与答

有用过 jq 命令行工具处理 json 数据的么,请教个传参的问题

  •  
  •   yuedingwangji · Nov 25, 2017 · 1696 views
    This topic created in 3242 days ago, the information mentioned may be changed or developed.

    我在 shell 中定义了 a=‘ wwwbaiducom ’

    现在我有一个 json 文件,a.json

    cat a.json | jq '.records[] |select(.name=="$a")|.id' 没有返回任何结果

    正确的返回结果 root@bdwaf:/srv/salt/shell/dnspod/online# cat dnspod_record | jq '.records[] |select(.name=="wwwbaiducom")|.id'

    "232960110"

    请问怎么将 shell 变量传递给 jq 去解析呀

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1002 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 22:56 · PVG 06:56 · LAX 15:56 · JFK 18:56
    ♥ Do have faith in what you're doing.