使用Bash进行字符串格式化

时间:2016-08-23 11:30:12

标签: bash shell

我正在编写形成json文件的bash脚本:

[14:09:26][Step 4/4] {
[14:09:26][Step 4/4]    "release":{
[14:09:26][Step 4/4]       "version":null
[14:09:26][Step 4/4]    },
[14:09:26][Step 4/4]    "product":{
[14:09:26][Step 4/4]       "group":"CMS",
[14:09:26][Step 4/4]       "name":"CMS_prod",
[14:09:26][Step 4/4]       "version":"_VERSION_"
[14:09:26][Step 4/4]    },
[14:09:26][Step 4/4]    "application":{
[14:09:26][Step 4/4]          "name":"OAPI",
[14:09:26][Step 4/4]          "appl_id":"6150",
[14:09:26][Step 4/4]          "version":"_VERSION_",
[14:09:26][Step 4/4]          "date":"_DATE_",
[14:09:26][Step 4/4]          "detail":null,
[14:09:26][Step 4/4]          "vcs":{
[14:09:26][Step 4/4]             "hash":null,
[14:09:26][Step 4/4]             "branch":null
[14:09:26][Step 4/4]          },
[14:09:26][Step 4/4]          "build":{
[14:09:26][Step 4/4]             "number":null,
[14:09:26][Step 4/4]             "url":null
[14:09:26][Step 4/4]          }
[14:09:26][Step 4/4]       }
[14:09:26][Step 4/4] }
[14:09:26][Step 4/4] VERSION: 003.09
[14:09:26][Step 4/4] DATE: 2016-08-23:14:09:26
[14:09:26][Step 4/4] {
[14:09:26][Step 4/4]    "release":{
[14:09:26][Step 4/4]       "version":null
[14:09:26][Step 4/4]    },
[14:09:26][Step 4/4]    "product":{
[14:09:26][Step 4/4]       "group":"CMS",
[14:09:26][Step 4/4]       "name":"CMS_prod",
[14:09:26][Step 4/4]       "version":"003.09"
[14:09:26][Step 4/4]    },
[14:09:26][Step 4/4]    "application":{
[14:09:26][Step 4/4]          "name":"OAPI",
[14:09:26][Step 4/4]          "appl_id":"6150",
[14:09:26][Step 4/4]          "version":"_VERSION_",
[14:09:26][Step 4/4]          "date":"2016-08-23:14:09:26",
[14:09:26][Step 4/4]          "detail":null,
[14:09:26][Step 4/4]          "vcs":{
[14:09:26][Step 4/4]             "hash":null,
[14:09:26][Step 4/4]             "branch":null
[14:09:26][Step 4/4]          },
[14:09:26][Step 4/4]          "build":{
[14:09:26][Step 4/4]             "number":null,
[14:09:26][Step 4/4]             "url":null
[14:09:26][Step 4/4]          }
[14:09:26][Step 4/4]       }
[14:09:26][Step 4/4] }

它的控制台出来了:

leftBarButtonItem

DATE 已设置,但 VERSION 不,我无法理解原因。请帮我解决这个含糊不清的问题。

也许有更多美丽的方式来做,脚本在TeamCity的构建代理服务器中执行。

0 个答案:

没有答案