【发布时间】:2021-01-05 00:22:34
【问题描述】:
使用 bash 在结束括号 } 后添加逗号。
使用
sed 's/variable/&,/g;s/,$//'
在variable 之后添加逗号,但是,
sed 's/}/&,/g;s/,$//'
没用。
输入:
variable "policy_name1" {
description = "abc xyz"
type = string
default = [
"test1"
"test2"
]
}
variable "policy_name2" {
description = "abc xyz"
type = bool
default = false
}
输出:
variable "policy_name1" {
description = "abc xyz"
type = string
default = [
"test1"
"test2"
]
},
variable "policy_name2" {
description = "abc xyz"
type = bool
default = false
}
【问题讨论】:
-
@F.Hauri 对,我在考虑
sed -E/sed -r的行为! -
您已经打开了一个包含相同示例文件的问题,并且您想要解析它并提取值。以防万一您认为必须准备此文件以进行解析(我认为这是个好主意),在此处添加逗号似乎没有帮助。 stackoverflow.com/questions/63948922/…