我正在尝试这种sed操作并且没有发生
sed -e 's/\<\* \* \* \* \* \/opt\/scripts\/centralizedLogging\>/\<0 0 \* \* \* \/opt\/scripts\/centralizedLogging\>/g' /etc/cron.d/jobs
另一方面,这是有效的:
sed -e 's/\<0 0 \* \* \* \/opt\/scripts\/centralizedLogging\>/\<\* \* \* \* \* \/opt\/scripts\/centralizedLogging\>/g' /etc/cron.d/jobs
答案 0 :(得分:0)
sed -e 's#<\([*][[:blank:]]\{1,\}\)\{2\}\(\([*][[:blank:]]\{1,\}\)\{3\}/opt/scripts/centralizedLogging>\)#<0 0 \2#g' /etc/cron.d/jobs
[[:blank:]]\{1,\}
代替
更加通用,[*]
更容易捕捉而不是含糊不清(阅读时)\*
#
作为分隔符而非传统/
我强烈建议在cron作业或同化
上进行此类操作时使用备份文件