API JSON get ID from bash -


just wondering if me "snapshotid" first record output curl command outputs below? have tried jq

"parse error: invalid numeric literal @ line 1, column 6"

any other ideas?

{      "9875a8e4fc31f3":{         "snapshotid":"98758e4afc31f3",       "date_created":"2017-04-05 10:16:17",       "description":"centminmod",       "size":"42949672960",       "status":"complete"    },    "b0d58e5b0d46e":{         "snapshotid":"b0d58e5b0d46e",       "date_created":"2017-04-05 23:07:00",       "description":"serverpilot",       "size":"42949672960",       "status":"complete"    },    "d3158e6fbaa204":{         "snapshotid":"d3a158e6fba204",       "date_created":"2017-04-06 22:38:26",       "description":"",       "size":"42949672960",       "status":"complete"    },    "39a58ae6fe12f0":{         "snapshotid":"39aa58e6fe1a2f0",       "date_created":"2017-04-06 22:48:50",       "description":"",       "size":"42949672960",       "status":"complete"    },    "51458ea70124c7":{         "snapshotid":"514a58e701a24c7",       "date_created":"2017-04-06 23:01:56",       "description":"",       "size":"42949672960",       "status":"complete"    },    "b2a58e7a04af99":{         "snapshotid":"b2a5a8e70a4af99",       "date_created":"2017-04-06 23:17:03",       "description":"",       "size":"42949672960",       "status":"complete"    },    "17b58e70a7133c":{         "snapshotid":"17b58ae7a07133c",       "date_created":"2017-04-06 23:27:15",       "description":"",       "size":"42949672960",       "status":"complete"    },    "32958e70aa0acf":{         "snapshotid":"32958eaa70a0acf",       "date_created":"2017-04-06 23:39:54",       "description":"",       "size":"42949672960",       "status":"complete"    },    "dfa58e70d63a57":{         "snapshotid":"dfa58ea70d6357",       "date_created":"2017-04-06 23:54:11",       "description":"",       "size":"42949672960",       "status":"complete"    },    "96358e712bf80":{         "snapshotid":"96358e7a12bf80",       "date_created":"2017-04-07 00:17:03",       "description":"",       "size":"0",       "status":"pending"    } } 

maybe bit overcomplicated works:

grep snapshotid | head -n 1 | sed "s/[^\"']*.snapshotid.[^\"']*.\([^\"']*\).*/\1/"


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -