-   Linux - Newbie (
-   -   awk scripts (

jdeeptir 05-23-2008 12:15 AM

awk scripts
Dear ALL,
How can i check multiple conditions in awk.It is giving me error
if i type this command

`cat /k2 |awk -v d1="$d" -v m1="$m" -v t1="$t" -v mins="$min" '{if ( $7 == d1 ) {if ( $6 == m1 ) { if ( $8 == t1 ) { if ( $9 > 4 ) {print $10}}}}}' >/kk`

where d=9,m=2,t=20,min=30;

I cant execute this awk command.
Is there any othere way.Please help me.

With Regards,

archtoad6 05-23-2008 07:19 AM

What error are you getting?

Please provide a short sample of k2 in a separate "Code:" block.

Please put code in "Code:" blocks, it makes it easier to read. (If you don't understand "Code:" blocks, ask.)

I assume you have checked the GNU (g)awk manual
Especially here:

PMorph 05-23-2008 01:11 PM

Don't know what's the problem there, but wouldn't it be more convenient to use ANDs?

{if ( $7 == d1 && $6 == m1 && $8 == t1 && $9 > 4 ) {print $10} }

archtoad6 05-23-2008 01:20 PM

Good idea, PMorph.

jdeeptir, where's that sample?

archtoad6 06-06-2008 10:34 AM

Well . . .

colucix 06-06-2008 12:43 PM

archtoad6, don't worry... this is a kind of user which never replies. There are plenty of them out there. Maybe it's a problem of their short-term memory synapses... ;)

archtoad6 06-07-2008 10:30 AM

You're right -- I checked his threads/posts -- he seems to not have the courtesy to answer helpers' follow-up Q's. I wonder if he doesn't know about automatically subscribing to his own threads & opting for the e-mail that that sends.

Is this rude enough to warrant a report?

Would it be too rude to post a note about this thread in one of his others -- something like
"Dude please answer your helpers' follow-up Q's at"

colucix 06-09-2008 05:35 AM

I don't think it's a matter of being rude or not. I wonder why it is so important. If the OP is not enough intersted in finding a solution to his problem, despite the helper's efforts, why should we care? I understand it can be irritating, but I prefer to go on and ignore the thread as the OP ignored it and the people who tried to help. It's not worth losing more time.


archtoad6 06-09-2008 08:28 AM

You're right about losing more time; but I was really interested in the problem, & I am "upset" (read pissed off) that I am not going to get the chance to do so. Furthermore, this may be a cultural difference, but where I come from it's f'g rude to ask a Q & not listen to the answer.

Tinkster 06-09-2008 02:18 PM


but where I come from it's f'g rude to ask a Q & not listen to the answer.
So you're not parent to teen-agers, I guess ... :D

And this REALLY is enough on this subject. Thread-jacking for
the purpose of venting is about as rude as not responding to
the inquiries from potential helpers.


All times are GMT -5. The time now is 12:46 AM.