在perl脚本中我要用到系统命令,
通过system()可以完成。
但是当我写到:
$str=system ("tail -f /tmp/test.log |grep -E aaa|bbb");
时候它提示aaa|bbb中的“|bbb”不是bash命令。。。
它把或看成管道了。。
我改成:
$str=system ("tail -f /tmp/test.log |grep -E "aaa|bbb"");
或者:
$str=system ("tail -f /tmp/test.log |grep -E (aaa|bbb)");
等都不行。
请问应该怎样才能达到目的?求高手指教。。
木子leal 于 2011-08-08 09:53:36发表:
:0wszxc
年年年 于 2011-08-04 09:39:33发表:
3# 奶茶dsk
谢谢奶茶!双引号加上反斜杠就可以了。。
奶茶dsk 于 2011-08-03 19:27:10发表:
没用过perl,,应该差不多,
$str=system ("tail -f /tmp/test.log |grep \"aaa\\|bbb\"");
或者
$str=system ("tail -f /tmp/test.log |grep -E \"aaa|bbb\"");
都试试吧
sy20577037 于 2011-08-03 15:50:30发表:
ding