awk sucks

Why the hell would awk return a value of 1 when I say

awk ‘{ if ( $9 == “step” ){ print $9 }}’ $mut1 > $out1

and the value in that column is 0?  Isn’t this a string comparison?  Why does 0 == “step” ?  Makes no sense.  This fixed it though, after 20 minutes of trouble shooting.  Stupid awk.

awk ‘{ if ( $9 ~ /step/ ){ print $9 }}’ $mut1 > $out1

Easier if you just do everything in Assembly, you know.

:o ;D
Easier for whom?

Certainly not me, although I’m a PHP developer.

Ugh, I’m off to bed.  This script is taking forever, and I’m tired/bored.  Thanks for replying phil. :slight_smile:

Hey, no problem. At least you don’t have to write a how-to for a rather technically un-savvy client. Sigh.

A few decades ago I was programming assembly on a DEC VAX11-750 and learning how to fly airplanes. The airplanes won. I do remember that syntax is everything… (after flow charts of course…)

Whatcha fly Oscarvan?

I was Civil Air Patrol when I was younger and am about 10 hours shy of my Single Engine rating. I’m sure that doesn’t compare to what you’re flying, but I was curious.

FWIW the local air club here has so great vintage WWII fighters and bombers - ME109s, P-51s, and a Zero. I haven’t joined the club yet, so I dunno if they let you check 'em out, but I should probably go ask.

Nothing exotic…people movers. Started on the 727 then DC-9, B737 200/300/500/700/800/900 Nowadays B757 200/300 and B767 200/400 Lost track of my hours a long time ago. It’s a job. A good job, but it’s a job.

Don’t know PHP, but possibly data type error? If it can’t evaluate $9 as equal to a given string because $9 isn’t a string… Like I said, I don’t know PHP at all.

I miss 65C02 assembler.

Dunno, your first example should work.

Note that your regular expression in the second example is searching for any string containing the substring “step”.  If you want to match only the entire word, you need to use /^step$/

Thanks Nate.  I don’t know, but either way it is fixed.  Unfortunately since I went to bed and wasn’t watching the computer rebooted in the middle of the script so it could update the virus protection . . . so now I’m re-running the script and it’s moving even slower now than last night. :cry:

Yeah, that’s fine though because the only line that contains anything that matches is the first line, which is the one I’m trying to pull out of the file with that part of awk - the bit I included was just my troubleshooting line, the actual line is below.  I suspect it has something to do with it running inside of a perl script so I can pipe in a list of directories to go through, but either way it is working as expected now.

awk ‘{ if ( $9 ~ /step/ || ( $8 > 2499999 && $8 < 27500001 )) {print $0}}’ $mut1 > $out1