The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's manas6 UNIX for Dummies Questions & Answers 0 06-05-2008 03:44 AM
Shell script to catch PL/SQL return values Veera_Raghav Shell Programming and Scripting 0 06-26-2006 02:16 PM
Possible return values for $? 435 Gavea Shell Programming and Scripting 3 01-03-2006 10:06 PM
perl "system" cmd return values.. sekar sundaram Shell Programming and Scripting 0 11-24-2005 04:00 AM
exit/return values vslewis UNIX for Dummies Questions & Answers 1 11-17-2004 11:12 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-09-2008
Registered User
 

Join Date: May 2008
Posts: 8
Stumble this Post!
Exclamation Help: return values from awk

Hi.
I have a script like this:

nawk 'BEGIN {FS=","; TOT1=0; REJ1=0;} {
if($7=="TOTAL") { TOT1=TOT1 +$8}
if($7=="REJS") { REJ1=REJ1 +$8}

}' FILE_123.dat

and what I need is to be able to use the values stored in TOT1 and REJ1 in the unix env to compare them and decide if send an email or not like this:

if [ $REJ1 > $TOT1/30 ] { mailx xxxxxxxxxx }

How can I read/use those values out of the awk?

Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-09-2008
reborg's Avatar
Administrator
 
Join Date: Mar 2005
Location: Ireland
Posts: 3,513
Stumble this Post!
print out the values ( for example )

"REJ1=someting"

Then use eval to call the nawk.


example:
Code:
# echo world | nawk '{ print "hello=" $1 }'
hello=world
# eval $(echo world | nawk '{ print "hello=" $1 }')
# echo $hello
world
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0