V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
holinhot
V2EX  ›  问与答

grep -Po 使用问题

  •  
  •   holinhot · 2016-06-25 14:43:08 +08:00 · 1887 次点击
    这是一个创建于 2883 天前的主题,其中的信息可能已经有所发展或是发生改变。
    {
    "result":[
    {
    "id":"652bcd",
    "type":"1",
    "name":"san",
    "content":"santest",
    "created_on":"2016-03-22T01:41:55",
    "meta":{
    "auto_added":false
    }
    }
    ],
    "result_info":{
    "count":1,
    "total_count":1
    },
    "success":true,
    "errors":[
    ],
    "messages":[
    ]
    }

    怎么才能抓取{"id":"652bcd","type":"1","name":"san","content":"santest","created_on":"2016-03-22T01:41:55","meta":{"auto_added":false}}
    这一部分内容
    抓取名字我用的 grep -Po '(?<="name":")[^"]*'
    3 条回复    2016-06-26 18:09:19 +08:00
    SoloCompany
        1
    SoloCompany  
       2016-06-25 17:42:26 +08:00
    npm install node-select

    echo '{
    "result":[
    {
    "id":"652bcd",
    "type":"1",
    "name":"san",
    "content":"santest",
    "created_on":"2016-03-22T01:41:55",
    "meta":{
    "auto_added":false
    }
    }
    ],
    "result_info":{
    "count":1,
    "total_count":1
    },
    "success":true,
    "errors":[
    ],
    "messages":[
    ]
    }
    ' | ./node_modules/.bin/json-select 'result.*'
    [
    {
    "id": "652bcd",
    "type": "1",
    "name": "san",
    "content": "santest",
    "created_on": "2016-03-22T01:41:55",
    "meta": {
    "auto_added": false
    }
    }]
    ericFork
        2
    ericFork  
       2016-06-26 18:09:04 +08:00
    用 jq 或者 pip 到 python -c
    ericFork
        3
    ericFork  
       2016-06-26 18:09:19 +08:00
    @ericFork *pipe
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1043 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:45 · PVG 06:45 · LAX 15:45 · JFK 18:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.