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
How to assign a variable value to array? balamv Shell Programming and Scripting 2 06-06-2008 04:33 AM
split variable values into array finalight Shell Programming and Scripting 4 05-21-2008 04:21 AM
Help in passing array of inputs to C program using script? ahjiefreak Shell Programming and Scripting 1 03-20-2008 07:36 AM
creating array variable scriptingmani Shell Programming and Scripting 2 06-28-2007 11:25 AM
Array help (variable substitution). dsimpg1 Shell Programming and Scripting 3 04-11-2007 05:38 PM

 
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 05-09-2005
whatisthis's Avatar
whatisthis whatisthis is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 175
AWK program with array variable

Hi,
I made a small awk program just to test array variables.
I couldn't find anything wrong with it.
But it doesn't give out valid numbers.( just 0.00 )
Do you see any problem that I didn't see?

Thanks in advance!

Here is the program:

##################################
BEGIN {
FS = ","
}

{
job = $2
station = $3
time_period = substr($6,1,3)
wait= $11
if (station > 0) {
while ( y <=24 ) {
++y
if ( time_period == y ) {
hour[y] += wait
++i[y]
}

}

}
}
END {
y = 0
while ( z <= 24 ) {
++z
++y
if ( i[y] > 0 ) {
AVG[z]=hour[y]/i[y]
printf("%9.2f\n",AVG[z])
}
}
}

###################################

Here is one row of my data file:
17.11.2004,5189400,222,12538476808, 215, 23:51:01, 23:51:14, 23:51:27, 13, 0, 13, d, 1, 0, 20718, (253)847-6, 1303, -1, 23:51:04, 23:51:04, 0, 23, 3, 1, 2, 0, respo, DEL

Last edited by whatisthis; 05-10-2005 at 09:29 AM.. Reason: typo
 

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 01:10 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