LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 05-23-2008, 12:15 AM   #1
jdeeptir
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Rep: Reputation: 0
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,
Deepti
 
Old 05-23-2008, 07:19 AM   #2
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
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: http://www.gnu.org/software/gawk/man...onditional-Exp
 
Old 05-23-2008, 01:11 PM   #3
PMorph
Member
 
Registered: Sep 2003
Distribution: Debian
Posts: 213

Rep: Reputation: 31
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} }
 
Old 05-23-2008, 01:20 PM   #4
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
Good idea, PMorph.

jdeeptir, where's that sample?
 
Old 06-06-2008, 10:34 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
Well . . .
 
Old 06-06-2008, 12:43 PM   #6
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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...
 
Old 06-07-2008, 10:30 AM   #7
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
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 http://www.linuxquestions.org/questions/showthread.php?t=644194"
 
Old 06-09-2008, 05:35 AM   #8
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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.

Alex
 
Old 06-09-2008, 08:28 AM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
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.
 
Old 06-09-2008, 02:18 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Quote:
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.


Cheers,
Tink

Last edited by Tinkster; 06-09-2008 at 02:19 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 07:23 AM
Some comments on awk and awk scripts makyo Programming 4 03-02-2008 06:39 PM
Value counting in awk scripts sarajevo Programming 9 10-20-2006 09:24 AM
Help needed in writing Awk Scripts.. TheDarktrooper Red Hat 1 05-04-2004 07:49 PM
Getting awk to extract scripts from a file jspaceman Programming 5 11-24-2002 07:37 PM


All times are GMT -5. The time now is 11:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration