如何egrep包含变量的多个短语

时间:2014-09-02 00:08:40

标签: shell grep

for svc in a b c d
 do
 service_status=$(service xy-mp-$svc status)
 if echo $service_status | egrep -i 'xy-mp-"$svc" dead but pid file exists|xy-mp-"$svc" is   stopped' &> /dev/null
 then
      service xy-mp-$svc restart
 fi             
 done

使用“$svc”,变量替换不会发生在egrep中。在此示例中,是否有人对如何进行变量替换有任何想法?

欣赏任何指示。

0 个答案:

没有答案
相关问题