输入多个目录中的文件,并希望将现有索引名称更改为index = windows_pr和index = windows_np。
显示的 WinEventLog 块全部位于名为 input.conf 的同一文件中,但驻留在名称不同的文件夹中,如 A. (EVZ_pr_windows/inputs.conf) 和 B (DEG_np_windows/inputs.conf)。因此,任何索引以 _pr 结尾的文件节都将位于文件夹 A inputs.conf 中,而任何索引以 _np 结尾的文件节将位于文件夹 B input.conf 中。该脚本应将以 _pr 结尾的索引更改为 index = windows_pr 并将以 _np 结尾的索引更改为 index = windows_np
input.conf 中的 WinEventLog 块仅限于应用程序、安全性、系统、ForwardedEvents 和设置
我尝试这个但出现错误
下面是错误
\]_,/s/.*index.*=.*pr$/index = window_pr/' inputs.conf
sed:-e表达式#1,字符69:未终止的地址正则表达式
#!/bin/bash
sed -E -i '\_\[WinEventLog://(Application|Security|System|ForwardedEvents|Setup)
\]_,/s/.*index.*=.*np$/index = window_np/' inputs.conf
sed -E -i '\_\[WinEventLog://(Application|Security|System|ForwardedEvents|Setup)
\]_,/s/.*index.*=.*pr$/index = window_pr/' inputs.conf
[WinEventLog://Application]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = CNDO_pr
[WinEventLog://Security]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = CGWS_pr
[WinEventLog://System]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = DMRW_pr
[WinEventLog://ForwardedEvents]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = NENP_pr
[WinEventLog://Setup]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = EOFK_pr
[WinEventLog://Application]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = FDWD_np
[WinEventLog://Security]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = ASKD_np
[WinEventLog://System]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = JMSF_np
[WinEventLog://ForwardedEvents]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = JCCD_np
[WinEventLog://Setup]
checkpointInterval = 5
current_only = 0
disabled =0
start_from = oldest
index = HSMS_np
答案1
考虑到错误消息并假设表达式 #1 以 开头\\_
,该表达式的字符 69 似乎_
紧随其后]
。因此,我猜您需要一个\
前缀来_
为表达式提供适当的终止符。