Interesting, but unfortunally, a bit slow. grep rocks when it comes to speed:
#!/bin/sh
FILE=/home/abigail/Words/enable.lst
PATTERNS="
abc
sch[ae]
.*a.*e.*i.*o.*u.*
^[[:xdigit:]]+$
(a|b)(c|d)(e|f)
"
PROGRAMS=("/bin/grep -E" ./grepp)
OUTPUT=(/tmp/grep.out /tmp/grepp.out)
i=0
while [ $i -lt ${#PROGRAMS[*]} ]
do echo -n ${PROGRAMS[$i]}
time for pat in $PATTERNS
do ${PROGRAMS[$i]} $pat $FILE
done > ${OUTPUT[$i]}
i=$((i + 1))
done
i=1
while [ $i -lt ${#OUTPUT[*]} ]
do diff ${OUTPUT[0]} ${OUTPUT[$i]}
i=$((i + 1))
done
rm -f ${OUTPUT[*]}
/bin/grep -E
real 0m0.070s
user 0m0.060s
sys 0m0.010s
./grepp
real 0m2.774s
user 0m2.610s
sys 0m0.030s
Abigail
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|