July 22, 2004
pcregrep VS grep::[Misc]

since grep can't support binary or extend-coding, I change most of my scripts to pcregrep.
To my surprise, the script runing much faster after I switch to pcregrep:
Here is a example:
mcfarm:~/work/rootfit/background-only-step1/output$ time pcregrep 1000 exper.1.data > /dev/null
0.940u 0.030s 0:00.97 100.0% 0+0k 0+0io 103pf+0w
mcfarm:~/work/rootfit/background-only-step1/output$ time grep 1000 exper.1.data > /dev/null
28.350u 0.470s 0:29.45 97.8% 0+0k 0+0io 155pf+0w
0.94 VS 28.35 !!!
Generally say, pcregrep is more than 20 times faster then grep.
Posted at July 22, 2004 11:20 PM by Liang at 11:20 PM | Comments (2) | TrackBack(0) | Booso!| Niu.la收藏!
pcregrep searches files for character patterns, in the same way as other grep commands do, but it uses
the PCRE regular expression library to support patterns that are compatible with the regular expressions
of Perl 5. See pcre(3) for a full description of syntax and semantics.If no files are specified, pcregrep reads the standard input. By default, each line that matches the pat-
tern is copied to the standard output, and if there is more than one file, the file name is printed
before each line of output. However, there are options that can change how pcregrep behaves.
Trackback
You can ping this entry by using http://www.wespoke.com/cgi-bin/mt/mt-tb.cgi/542
Comments
what's wrong with pcregrep as the following:
E:\pcre\bin>pcregrep -i 'aba' a.txt
E:\pcre\bin>type a.txt
aba
bcb
tct
E:\pcre\bin>
it outputs empty. But first line is a match!
您的留言必需含有中文字符
Posted by: haha at March 9, 2006 05:16 PM from 24.109.28.143楼上的 你使用grep一样得不到结果
我想可能是因为它把''也当成必须出现的字符而不是引号来处理了
如果是双引号的话没这问题
Posted by: 无双 at April 3, 2006 07:27 PM from 58.240.95.199