Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking to run an AWK script that is too slow in Perl?

Status
Not open for further replies.

gimiluv

Technical User
Oct 31, 2007
1
US
Hello, I have a perl script that seems to be running too slow and I was told than awk could possible speed up 2M+ lines of parsing. The output I'm going through looks as follows:
07:07:05.048 I: QFEED: S=BOL P=44.25 B=23.5 A=15.43 SZ=4200x1500 L=0 D=0(42) CD=0 N=1

What I need to do is find out if the value of A is less than the value of B, if So, print the line. But it's doing it on about 2-4M lines of code. I know k-shell is only capable of doing integers, so I thought I would try awk. Any ideas?
 
[tt]

Perhaps this...

$ cat script
/[A-Z]/ {
b=sprintf("%s", substr($6,index($6,"=")+1,5))
a=sprintf("%s", substr($7,index($7,"=")+1,5))

if(a<b) {print $0}
}

$ cat data
07:07:05.048 I: QFEED: S=BOL P=44.25 B=23.5 A=15.43 SZ=4200x1500 L=0 D=0(42) CD=0 N=1
07:07:05.048 I: QFEED: S=BOL P=44.25 B=23.5 A=55.43 SZ=4200x1500 L=0 D=0(42) CD=0 N=1
07:07:05.048 I: QFEED: S=BOL P=44.25 B=23.5 A=85.43 SZ=4200x1500 L=0 D=0(42) CD=0 N=1


$ awk -f script data
07:07:05.048 I: QFEED: S=BOL P=44.25 B=23.5 A=15.43 SZ=4200x1500 L=0 D=0(42) CD=0 N=1


[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top