How to add a header to CSV export in jq?

后端 未结 3 2222
滥情空心
滥情空心 2021-02-18 23:30

I\'m taking a modified command from the jq tutorial:

curl \'https://api.github.com/repos/stedolan/jq/commits?per_page=5\' \\
| jq -r -c \'.[] | {mes         


        
3条回答
  •  猫巷女王i
    2021-02-18 23:51

    Just add the header text in an array in front of the values.

    ["Commit Message","Committer Name"], (.[].commit | [.message,.committer.name]) | @csv
    

提交回复
热议问题