![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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... |
|
||||
|
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. |
![]() |
| Bookmarks |
| Tags |
| awk, commands, error, for loop, multiple |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|