Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi, Scrutinizer.
Quote:
Originally Posted by Scrutinizer
@drl, grep cannot do this and I do not think cgrep is present on Solaris, is it? cgrep looks nice though and it is fast indeed. I presume cgrep was tested against gawk, which is one of the slowest awks. Perhaps you could compare it to the fastest awk, which is mawk..
I have only the old Solaris-X86 running in a VM:
There are a number of repos which may have it, but I have not searched extensively. I can try to see if cgrep will compile on Solaris (it was an easy make on Linux, both 32-and-64-bit), but that will be a low-priority task.
An excerpt from a searching benchmark on a 100MB file shows:
So for that task the versions used were:
Best wishes ... cheers, drl
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi, Scrutinizer.
Thanks for spotting that anomaly. In fact, I was using GNU/awk for mawk. The new (interim) excerpt of the searching benchmark is:
which shows that for this task, mawk is 2-3 times faster than gawk in CPU time (although, like cgrep, the system time is greater).
I'm sure that Michael appreciates you defending his code's honor
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
This is a quickly-put-together script:
producing:
If there is something that takes a cache hit, it would be the wc, or at least the cgrep ... cheers, drl
With an input file, similar to your Moby Dick and not directly related to the problem at hand in this thread (and with which there were no matches) I also get a factor 5 difference between gawk and mawk, so your result may be a compile thing?. The difference between cgrep and mawk is a factor 6.
With an input file that is a large version of the input file of the problem in this thread, mawk and cgrep are about the same speed, with mawk being 5-10% faster than cgrep, while the difference between mawk and gawk was still a factor 5 - 5.5
---------- Post updated at 01:36 AM ---------- Previous update was at 01:34 AM ----------
Quote:
Originally Posted by drl
Hi.
This is a quickly-put-together script:
producing:
If there is something that takes a cache hit, it would be the wc, or at least the cgrep ... cheers, drl
Hello,
Thank you very much for your effort, looks like very good craftsmanship, unfortunately I cannot test anyware as I don;t have cgrep on any of my machines.
I have a large dataset with following structure;
C 0001 Carbon
D SAR001 methane
D SAR002 ethane
D SAR003 propane
D SAR004 butane
D SAR005 pentane
C 0002 Hydrogen
C 0003 Nitrogen
C 0004 Oxygen
D SAR011 ozone
D SAR012 super oxide
C 0005 Sulphur
D SAR013... (3 Replies)
I have a file lake this
cat ex1.txt
</DISCOUNTS>
<B2B_SPECIFICATION elem="0">
<B2B_SPECIFICATION elem="0">
<DESCR>Netti 2 </DESCR>
<NUMBER>D02021507505</NUMBER>
</B2B_SPECIFICATION>
<B2B_SPECIFICATION elem="1">
<DESCR>Puhepaketti</DESCR>... (2 Replies)
This is a variation of an earlier post found here:
unixcom/shell-programming-scripting/159821-merge-two-non-consecutive-lines.html
User Bartus11 was kind enough to solve that example.
Previously, I needed help combining two lines that are non-consecutive in a file. Now I need to do the... (7 Replies)
I have several very large file that are extracts from Oracle tables. These files are formatted in XML type syntax with multiple entries like:
<ROW>
some information
more information
</ROW>
I want to grep for some words, then print all lines between <ROW> AND </ROW>. Can this be done with AWK?... (7 Replies)
i need to grep a STRING_A & the next few lines after the STRING_A
example file:
STRING_A yada yada
line 1
line 2
STRING_B yada yada
line 1
line 2
line 3
STRING_A yada yada
line 1
line 2
line 3
line 4
STRING_A yada yada
line 1
line 2
line 3
line 4 (7 Replies)
Hi experts,
I want to grep a number 9366109380 from a file but it will also show me the next 5 lines. Below is the example-
when i grep 989366109380, i can also see the next 5 lines.
Line 1. <fullOperation>MAKE:NUMBER:9366109380:PPAY2;</fullOperation>
Line 2.... (10 Replies)
need help on this. let say i hv 1 file contains as below:
STRING
Description bla bla bla
Description yada yada yada
Data bla bla
Data yada yada
how do i want to display n lines after the string?
thanks in advance! (8 Replies)