使用curl,我从github api获得了json:
curl https://api.github.com/repos/angular/angular/pulls?label=comp%3A+zones&state=closed&page=1&per_page=5
结果:
[
{
"url": "https://api.github.com/repos/angular/angular/pulls/33703",
"id": 338899730,
"node_id": "MDExOlB1bGxSZXF1ZXN0MzM4ODk5NzMw",
"html_url": "https://github.com/angular/angular/pull/33703",
"diff_url": "https://github.com/angular/angular/pull/33703.diff",
"patch_url": "https://github.com/angular/angular/pull/33703.patch",
"issue_url": "https://api.github.com/repos/angular/angular/issues/33703",
"number": 33703,
"state": "closed",
"locked": false,
"title": "add AOT mode default to version 9 upgrade doc",
[...]
使用jq:
$ curl 'https://api.github.com/repos/angular/angular/pulls?label=comp%3A+zones&state=closed&page=1&per_page=2' | jq --raw-output '.[] | "\(.id) \(.title)"'
我可以很好地将其格式化为
338899730 add AOT mode default to version 9 upgrade doc
338868666 update jiali's info on collaborator page of angular.io
如何在输出前从title值中删除add
和update
?
发布于 2019-11-11 23:58:54
使用sub
,例如:
.[]
| "\(.id) \(.title|sub("^(add|update) *";""))"
https://stackoverflow.com/questions/58801982
复制相似问题