如何将一些字符串附加到puppet中文件的现有行(而不是文件的结尾)?
原始文件如何将一些字符串附加到puppet中文件的现有行(而不是文件的结尾)?,puppet,Puppet,原始文件 # cat testfile one two three four 需要对文件进行更改 # cat testfile one two three mynum <-- string is added here four #cat测试文件 一 二 三个mynum如注释中所述,您可以使用匹配选项来文件行 试一试 match选项记录在 如果需要,可以将模式分解为变量: $line_pattern = 'three' file_line { 'add mynum to line s
# cat testfile
one
two
three
four
需要对文件进行更改
# cat testfile
one
two
three mynum <-- string is added here
four
#cat测试文件
一
二
三个mynum如注释中所述,您可以使用匹配
选项来文件行
试一试
match
选项记录在
如果需要,可以将模式分解为变量:
$line_pattern = 'three'
file_line { 'add mynum to line starting with three':
path => '/fullpath/testfile',
line => "${line_pattern} mynum",
match => "^${line_pattern} ",
}
第三行只是该行的一个占位符。这条线确实可以很大。“Mynum”必须附加在行的末尾。这很好。字符串three
可以分解成一个变量,Puppet可以处理我在寻找变量占位符的长行,这可能吗?e、 这样我就可以预先准备好线路了<代码>行=>“$1三个mynum”
$line_pattern = 'three'
file_line { 'add mynum to line starting with three':
path => '/fullpath/testfile',
line => "${line_pattern} mynum",
match => "^${line_pattern} ",
}