## [question] hard exercise, help needed

[question] hard exercise, help needed
# 1
09-20-2007
[question] hard exercise, help needed

Hello guys.

Well, on this exercise i need the average "chargeAmount" per hour (for each hour).

with this code :

i got the fields that i need, then with the awk comand i took the 1st and 4th fields separated by ":" .
But i couldnt get the total and average of chargeamount for each hour.

Hope you guys can help me again

 EnioMarques View Public Profile for EnioMarques Find all posts by EnioMarques
# 2
09-20-2007
Let's hope this is not homework.

add the following "pipe" to the end your existing line of code
 jim mcnamara View Public Profile for jim mcnamara Find all posts by jim mcnamara
# 3
09-21-2007
cat getusagesummarywrongmatch | grep -iv MOU2GRTObject | cut -d'|' -f4,14 | grep -i chargeamount | cut -d' ' -f2 | awk
-F':' '{cnt[\$1]++} {arr[\$1]+=\$4} END {for(i in arr) printf("Hour: %d Average: %.2f\n",i,arr[i]/cnt[i])}' | sort;

thanks a lot

Last edited by EnioMarques; 09-24-2007 at 10:20 AM.. Reason: worked!
 EnioMarques View Public Profile for EnioMarques Find all posts by EnioMarques

## Help with this exercise

you are to write a program which will read in a tax rate (as a percentage) and the prices of 5 items. the program is to calculate the total price, before tax, of the items and then the tax payable on those items, and then the total amount due. the tax payable is computed by appliying the tax rate...

## special question, hard to describe in few words...

dear coders, i need some inspiration again... there is something what i always wanted to know... how to code following: value 1: __________ value 2: __________ important: when my "script" starts the display has to be cleared and two lines are shown (see above), the cursor has to be...

## 3. Shell Programming and Scripting

I used to program ksh a while back, but I've been off in Oracle/Windows land (for clients -- not by choice) for so long that I can't remember what should be an easy thing. Here's the scenario: 1)Find all files and directories beneath some directory point (A). 2)If directory, make the...

## hard question

I have a directory containing a series of files of the format: A2008001231000.L2 I only care about the 6-8 digits, so the files are effectively: ?????---*.L2 I have files that range from ?????001*.L2 to ?????366*.L2 It should be noted these three digits represent the julian day of the...

## Simple question (for you guys, hard for me)

I am trying to exit this script by cd'ing into a particular directory. #!/bin/bash /opt/xxx/xxx/d2h \$1 fname=\$( /opt/xxx/xxx/d2h \$1) cd /opt/xxx1/xxx1 find . -name '*'\$fname'*' -ls cd /opt/xxx1/xxx1 Upon execution, it returns to my home directory (where I am running this script from. ...

## [question] trouble with an 'exercise'

Hello guys.. well, im kinda newbie with unix because i started to learn it like 2 weeks ago. then i started to make some exercises, but i got stucked on this one : so, i need to know how many different 'names' has the 5th field and how many times each name appears. i was trying with a...

## Hard Drive Question

Good day, I have an rs/6000 server, model 7044-270. I bought a 2nd hard drive for it but im not sure its the right one. (fru:H13060) As you surely know, the 7044-270 hard drives are put in some sort of tray/carrier. There is a cable that will interface the HDD with the tray/carrier so the...

## 8. UNIX for Dummies Questions & Answers

I am curious about one thing. Lets say I have a file file-a to which new generations are created on demand by simply archiving it (ex: file-a.tar.gz) and having the new one created with the same original filename file-a. Now what I want to know is if I create a hard/soft link to file-a, what...