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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Loop problem with one more problem aliahsan81 Shell Programming and Scripting 3 01-07-2009 02:02 AM
problem in finding a hardware problem girish.batra SUN Solaris 8 09-09-2008 11:10 AM
ssh script problem problem pcjandyala Shell Programming and Scripting 2 07-31-2008 04:27 PM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 11:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 10:12 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-23-2008
RRVARMA's Avatar
RRVARMA RRVARMA is offline
Registered User
  
 

Join Date: Feb 2008
Location: Bangalore, INDIA
Posts: 34
Question Problem in awk

Hi, I have a file (abc1.dat) with first field as table names and second field as previous months count and 3rd field as current months count. There are about 40 tables names in the file. This is the script I've written to find the percentage deviation for the two months.


Code:

cat ${workdir}/abc1.dat|awk '{ 
i = 0 
if ( $2 > $3 ) 
	 {
	 diff = $2 - $3 
	 i = 1
	 pd = ((($2 - $3) / $3) * 100)
	 } 
else if ( $3 > $2 ) 
	 {
	 diff = $3 - $2 
	 i = 1
	 pd = ((($3 - $2) / $2) * 100) 
	 } 

bteq << !!

.run file /db/d/lib/logon.script;

.SET SIDETITLES ON;
.SET TITLEDASHES OFF;

UPDATE AB_TABLE_${YYYY}
SET PD_ABC=$pd 
WHERE MONTHLY_TABLE_NAME LIKE '$1';

.QUIT; 

!!


errpct = $2 * 0.05 
if ( (i == 1) && (diff > errpct) ) 
{ printf "%-30s %-30d %-30d\n", $1, $2, $3 }
}' >> ${logdir}/errortables.log

The abc1.dat file looks like this

Code:
DB_YYYYMM                              3200867     3212612
DB_MASTER_YYYYMM                  5635623     5653570
DB_II_YYYYMM                           3200104     3211480
DB_MM                                      5635623     5653570
DB_I_YYYYMM                            5331904     5353944
DB_RAW_YYYYMM                       5723946     5740122

The error its showing is in the awk.

awk: Syntax error near line 16
awk: illegal statement near line 16
awk: illegal statement near line 18
awk: Syntax error near line 18
awk: bailing out near line 18

Please help me to solve this problem.
Thanks,
RRVARMA
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0