jq名称作为表上的新列

时间:2017-09-26 15:46:38

标签: json linux bash jq

我的人我有问题我使用jq命令行所以我想在一个标题上打印数组的名称,所以这就是它:

curl  -s http://cd0a4a.ethosdistro.com/?json=yes  | jq '.rigs'

这是主要的工作环节:

curl  -s http://cd0a4a.ethosdistro.com/?json=yes |jq -c '.rigs|."0d6b27",."50dc35"|[.version,.driver,.miner,"\(.gpus)/\(.miner_instance)"]|@    csv'|sed 's/\\//g;s/\"//g' |  gawk 'BEGIN{print  "version" "," "GPU_driver" "," "miner" "," "gpu"} {print $0}' | csvlook -I

结果:

| version | GPU_driver | miner    | gpu  |
| ------- | ---------- | -------- | ---- |
| 1.2.3   | nvidia     | ethminer | 2/2  |
| 1.2.4   | amdgpu     | ethminer | 1/1  |

但我需要它是这样的:

| version | GPU_driver | miner    | gpu  |  rigname  |
| ------- | ---------- | -------- | ---- |-----------|
| 1.2.3   | nvidia     | ethminer | 2/2  |  0d6b27   |
| 1.2.4   | amdgpu     | ethminer | 1/1  |  50dc35   |

0 个答案:

没有答案