V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
yuedingwangji
V2EX  ›  问与答

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

  •  
  •   yuedingwangji · Nov 25, 2017 · 1448 views
    This topic created in 3078 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   ·   Solana   ·   1144 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:59 · PVG 07:59 · LAX 16:59 · JFK 19:59
    ♥ Do have faith in what you're doing.