User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,772 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 922 | Replies: 0 | Solved
Reply
Join Date: Feb 2005
Posts: 92
Reputation: tones1986 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
tones1986 tones1986 is offline Offline
Junior Poster in Training

Bash Shell Script - sales/product/cost

  #1  
Nov 30th, 2007
Hey Folks. I have to write a script that will basically take input from 3 different files which contain the following:

product (file contains the following - FS=".")
-product ID (Int number)
-description (alphanumeric text)
-price (floating pt. number, with 2 sig. digits)

sales (file contains the following - FS=",")
-product ID (Int number)
- quantity (int number)
- date (in form DD:MM:YYYY)
- associate ID (int number)

associates (file contains the following - FS="/")_
- associate ID (int number)
- name (alphanumeric text)
- salary (int number)
- Position (aplhanumeric text)

I have to basically take these 3 files and use any method (would like to use awk, arrays, - the very basics if possible, not expert stuff, minmal the better - the better ill understand it).
I need to compute the saleas amount per associate for the year 2007 (not all dates are in 2007, some are 2006) and print them out listed ranked on sales totals.

I have an idea of how i would like to it by studying some notes.

Would something like this work?

salesInfo=()
awk -F/ '{salesInfo [$4] += $ }' sales

Sales file is:

110,1,01:02:2007,22
110,2,02:02:2007,23
109,1,03:03:2006,24
104,2,03:02:2007,24
104,3,03:02:2007,24
113,92,12:02:2007,24
.... about 20 more entries
product ID, quantity, date, empoyee ID (form of data)

How can i add up the associates total of sales per each item. For examle, associate 24 above sold items 109, 104 and 113...but sold 104 to two different customers (2 items to one, 3 to the other customer)... how can you add such a thing up? The above effort should be along the right lines, but how could i set it to do multiple...

Hope this is easy to understand for someone out there. Any ideas would be awesome. I just need a kick up the rear and ill get this working. Thanks folks.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 9:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC