我的sed命令有一个问题。得到字符串 ## flag robots.txt requests
SetEnvIf Request_URI "^/robots\.txt$" robots-request=log
## flag favicon requests
SetEnvIf Request_URI "^/favicon\.ico$" favicon-request=nolog
## flag image requests
SetEnvIf Request_URI "(\.gif|\.png|\.jpg)$" image-request=nolog
## flag Css and JS requests
SetEnvIf Request_URI \.css css-request=nolog
SetEnvIf Request_URI \.js js-request=nolog
## flag cron calls
SetEnvIf Request_URI "(^/cron\.php|^/bgp-start/)" cron-request=nolog
## set do_not_log if any of the above flags are set
SetEnvIf robots-request nolog do_not_log
SetEnvIf favicon-request nolog do_not_log
SetEnvIf image-request nolog do_not_log
SetEnvIf css-request nolog do_not_log
SetEnvIf js-request nolog do_not_log
SetEnvIf cron-request nolog do_not_log
,我需要在foooooooBaaaar
之前将逗号分开为Baaaar
。也许谁知道我该怎么做并能解释我?谢谢!
答案 0 :(得分:0)
在大写字母前插入逗号:
$ sed 's/[A-Z]/,&/' <<< "foooooooBaaaar"
fooooooo,Baaaar
<强>解释强>
s
:替换[A-Z]
:大写字母&
)在Baaaar
字符串之前添加逗号:
$ sed 's/Baaaar/,&/' <<< "foooooooBaaaar"