Aggregated points


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Aggregated points
# 1  
Old 10-08-2010
Aggregated points

Combine points of specific key (a1) based on user defined size (lets say 200 in this example).
so a1 191 and 191+200 and sum of all the values (4th column)
and vice versa...

Thanx a bunch!


Code:
a1 	191 	201 	1
a1 	201 	211 	2
a1 	211 	221 	1
a1	
.......
....
a2.........
.....
aT........
.........

output

Code:
a1	191	391	22
a1     391   591   66
..
a2	777	977	12
..
aT	100	300	66	
..

# 2  
Old 10-08-2010
How do you determine the user-defined size, is is passed as a parameter to the program or is it derived from the input?

Can't see any 4th column in the input or output, can you please specify how the 3 values in the output are supposed to be calculated.
# 3  
Old 10-08-2010
1. it is passed a parameter (200)
2.output
1st value =same as input (ex: a1)
2nd value= first value (ex: a1 191)
3rd value = second value (191,201,211,...untill it gets 391 (191+200)
4th value = is the sum of 1+2+1.... (of 191 -201, 201-211....391)
# 4  
Old 10-08-2010
so you need get the value every 200, but if 200 in the middle of line such as:

Code:
a1 	389 	395 	1

391 is in the middle, will you calculate 1 with which record? How do you handle it?
# 5  
Old 10-08-2010
Then print that one as it is in output. No need of any modification for such values.
# 6  
Old 10-08-2010
Here is a script that does the job just pass limit and datafile on command line eg:

Code:
$ sumdata 200 mydata.dat

Code:
#!/bin/ksh
gap=$1
start=0
limit=0
total=0
while read key min max amt
do
   if [ -n "$prev_key" -a "$key" != "$prev_key" ]
   then
       echo $prev_key $start $limit $total
       total=0
       limit=0
   fi
   if [ $limit -gt 0 -a $limit -lt $min ]
   then
       echo $prev_key $start $limit $total
       total=0
       limit=0
   fi
   if [ $limit -eq 0 ]
   then
       start=$min
       let limit=start+gap
    fi
    prev_key=$key
    let total+=amt
done < $2
echo $ckey $start $limit $total

# 7  
Old 10-08-2010
Code:
a1 191 391 26
a1 401 601 14
a1 2921 3121 20
a1 4781 4981 39
a1 4991 5191 1
a1 6051 6251 54
a1 6261 6461 73
a1 6471 6671 16

Hey than alot! It is working fine. is it possible to continue the flow 191:391-391-591....?means if it didnt find any thing it should print 0 like [a1 391 591 0].

Code:
a1 191 391 26
a1 391 591 0
a1 591 791 ...................

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Aggregated Etherchannel

Hi, I have a AIX5.3 P6-520 with 8x1Gb Ethernet ports with possible connections to 2 CISCO 2960 switches. I can create 8023ad Etherchannels which work correctly with the switches (I have set up for LACP passive and a valid channels) But can create 2x 8023ad 4Gb Etherchannels with no backups.... (2 Replies)
Discussion started by: spitzie
2 Replies

2. Shell Programming and Scripting

Count aggregated command output using wc -l

Hi all, I need to run a bunch of commands seperated by ; but then count the total lines of output. Pipes and redirection don't seem to be helping me. Anyone know how I can do this properly: ls /usr/bin/nslookup ; ls /usr/sbin/lsof ; ls /sbin/ifconfig ; ls /usr/sbin/dmidecode ; ls... (2 Replies)
Discussion started by: dan-e
2 Replies

3. UNIX for Dummies Questions & Answers

How to assign multiple IPs to Aggregated interface in Solaris 10?

I have 2 physical interfaces (bnx0 and bnx1) aggregated into aggr1. I need to assign second IP, and normally I know how to do it to physical interface (i.e. bnx0:1) however same trick (aggr1:1) is not working. Is there any way to do it? (0 Replies)
Discussion started by: bratan
0 Replies

4. Red Hat

Mount Points? How?

Hi folks, I have been asked to performed the following: Add the following new moint points systemA:/avp and SystemB:/usr/sap/trans to be the new linux server ZZZ How can I add those mount points and how those mount points can become another linuz server?:wall::wall::wall: (2 Replies)
Discussion started by: 300zxmuro
2 Replies

5. Post Here to Contact Site Administrators and Moderators

Points?

Has any thought been given to assigning points to threads much in the way the HP ITRC forums do? This might not be possible, just a thought. (1 Reply)
Discussion started by: candlejack
1 Replies

6. UNIX for Advanced & Expert Users

mount points

hi, I believe a mount point does not have to be a physical disk, but rather a logical one? Is this correct? if so, how can I find out if my mount points are on different physical disks? thanks (9 Replies)
Discussion started by: JamesByars
9 Replies

7. Shell Programming and Scripting

How can I get entries between two points

Hi, I am trying to write a script to get entries between two points lets say start and end points from a log file, the log file time format is as follows Start - 07/Aug/2008:18:26:43 End - 07/Aug/2008:19:36:43 I tried using the following awk command but it couldnt pick up the entries... (3 Replies)
Discussion started by: openspark
3 Replies

8. UNIX and Linux Applications

Gnuplot question: how to plot 3D points as colored points in map view?

I have a simple gnuplot question. I have a set of points (list of x,y,z values; irregularly spaced, i.e. no grid) that I want to plot. I want the plot to look like this: - points in map view (no 3D view) - color of each point should depend on its z-value. - I want to define my own color scale -... (0 Replies)
Discussion started by: karman
0 Replies

9. UNIX for Advanced & Expert Users

mount points

sometimes in Solaris 8 when I go to mount filesystems using either the mount command or by editing the /etc/vfstab, i get a nice little error message saying the the number of allowable mount points has been exceeded. I have read man pages until I am blue in the face and no where can I find what the... (3 Replies)
Discussion started by: manderson19
3 Replies
Login or Register to Ask a Question