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
Aix pid issue idana UNIX for Advanced & Expert Users 6 09-17-2009 10:24 PM
dbx issue mad_man12 High Level Programming 0 08-14-2009 09:03 AM
HP-UX Issue!! Ham HP-UX 1 05-16-2008 11:18 PM
Unix Arithmatic operation issue , datatype issue thambi Shell Programming and Scripting 23 02-19-2008 07:19 AM
FTP issue u263066 Shell Programming and Scripting 1 07-28-2006 07:18 AM

Reply
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
  #1 (permalink)  
Old 10-15-2009
alishehzadpaul alishehzadpaul is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 1
Issue in awk

In the following code, Im trying to imbed many statements in a single awk statement. But it gives an error on that,


Code:
for i in `less usage_types_dwh.txt`
do
cd /u01/app/evident/analysis_lab/usg_type
grep $i svc_type.txt | head -1 | awk 'BEGIN {FS=","} {print $1 "==" $2  ":" $3 ":" $4;
yesterday=$4;
day_before_yesterday=$3;
diff=day_before_yesterday-yesterday;
print "difference:" diff;
divide_by_2=day_before_yesterday/2;
print "Divide:" divide_by_2;
if ( divide_by_2 > 100 )
{
if ( divide_by_2 < diff )
{
print "****PERCENTAGE DECREASE****";
usg_type=$1;
divide_by_yes=diff/day_before_yesterday;
perc=divide_by_yes*100;
perc=perc*-1;
print "$usg_type | $perc %| $yesterday" >> /u01/app/evident/analysis_lab/ali/my_scripts/decrease_50_usagetypes.txt;
}
}
}'
cd /u01/app/evident/analysis_lab/ali/my_scripts
done

What am I doing wrong?

Last edited by pludi; 10-15-2009 at 08:07 AM.. Reason: code tags please...
  #2 (permalink)  
Old 10-15-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,949
What error do you get?

Last edited by pludi; 10-28-2009 at 07:49 AM..
  #3 (permalink)  
Old 10-15-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,119
Hi

As a start, have a look at this line:


Code:
print "$usg_type | $perc %| $yesterday" >> /u01/app/evident/analysis_lab/ali/my_scripts/decrease_50_usagetypes.txt;

Should be more like:

Code:
print usg_type "|" perc "%|" yesterday >> "/u01/app/evident/analysis_lab/ali/my_scripts/decrease_50_usagetypes.txt"

Please post the error.
Reply

Bookmarks

Tags
awk, commands, error, for loop, multiple

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 11:05 PM.


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