我想在多个文件中的现有字符串周围添加双引号。
check_envurl!ma100mlpapl002!-p 8080!-u / apollo / info?section = ERROR !!!!!
我想在第一个" -u"之后添加一个引号。但在/之前!所以它会是
check_envurl!ma100mlpapl002!-p 8080!-u" / apollo / info?section = ERROR" !!!!!
我尝试过更换sed但不符合标准
define service {
host_name ma100mlpapl002
servicegroups Environment URL
service_description http://ma100mlpapl002:8080/apollo/info?section=ERROR
display_name http://ma100mlpapl002:8080/apollo/info?section=ERROR
check_command check_envurl!ma100mlpapl002!-p 8080!-u /apollo/info?section=ERROR!!!!!
max_check_attempts 3
check_interval 15
retry_interval 1
check_period 24x7
contact_groups siteops
sed '/pattern/a some text here' filename
答案 0 :(得分:0)
试试这个:
$ sed 's/-u \([^!]*\)!/-u "\1"!/' <<< 'check_envurl!ma100mlpapl002!-p 8080!-u /apollo/info?section=ERROR!!!!!'
check_envurl!ma100mlpapl002!-p 8080!-u "/apollo/info?section=ERROR"!!!!!