Output JSON from Bash script

后端 未结 6 1352
暖寄归人
暖寄归人 2020-12-07 18:00

So I have a bash script which outputs details on servers. The problem is that I need the output to be JSON. What is the best way to go about this?

6条回答
  •  旧时难觅i
    2020-12-07 18:14

    I wrote a tiny program in Go, json_encode. It works pretty good for such cases:

    $ ./getDistro.sh | json_encode
    ["my.dev","Ubuntu 17.10","4 days, 2 hours, 21 minutes, 17 seconds"]
    

提交回复
热议问题