Number of occurance with multiple conditions??

Hi,

I the following sample of out put:

+ 6.07875 10 0 cbr 210 ------- 2 10.0 2.3 1461 19715
- 6.07875 10 0 cbr 210 ------- 2 10.0 2.3 1461 19715
+ 6.07875 22 0 cbr 210 ------- 2 22.0 2.9 1301 19716
- 6.07875 22 0 cbr 210 ------- 2 22.0 2.9 1301 19716
r 6.07922 0 1 cbr 210 ------- 1 30.0 2.27 58 19217
+ 6.07922 1 2 cbr 210 ------- 1 30.0 2.27 58 19217
d 6.07922 1 2 cbr 210 ------- 1 30.0 2.27 58 19217
- 6.0793 0 1 cbr 210 ------- 1 28.0 2.25 114 19298
r 6.07959 31 0 cbr 210 ------- 1 31.0 2.28 45 19627
.... .....      .....                       .....                ......

I need to calculate the following;
create the results in two new files:
File1 : contains the only results from id:2 ($7) [ ------- 2 10.0] AND time ($2) AND d ($1).
File2 : contains the only results from id: 1 ($7) [ ------- 1 30.0] AND time ($2) AND d ($1).

Then I need to calculate on each file number of occurances of "d" with relate to time and only from 1 2: explained down:

------------------------------------------------------------
d Time     from  To                 Id
-------------------------------------------------------------
d 6.07922   1     2  cbr 210 ------- 1 30.0 2.27 58 19217
-------------------------------------------------------------

expected output

------------------------------------------------------------
time            from               to               NumberOfOccurance
------------------------------------------------------------
6.07922        1                  2                      13
------------------------------------------------------------

:eek:
Best Regards,
Moe

Hi,

I would try to help, but can't understand the solution you are looking for.

I can't figure neither the output of both files nor the conditions to select lines of input file.

Regards,
Birei

$ awk '$8==2{print $7,$8,$9,$2,$1}' infile  > File1
$ awk '$8==1{print $7,$8,$9,$2,$1}' infile  > File2

$ cat File1
------- 2 10.0 6.07875 +
------- 2 10.0 6.07875 -
------- 2 22.0 6.07875 +
------- 2 22.0 6.07875 -

$ cat File2
------- 1 30.0 6.07922 r
------- 1 30.0 6.07922 +
------- 1 30.0 6.07922 d
------- 1 28.0 6.0793 -
------- 1 31.0 6.07959 r

or by one awk:

awk '{print $7,$8,$9,$2,$1 > "File" $8}' infile

Don't understand your second request.

Thank you for your reply...

You are right, My explanation was confusing ... I'll try to explain it again..

Suppose I have the following sample:

r 6.07922 0 1 cbr 210 ------- 1 30.0 2.27 58 19217
+ 6.07922 1 2 cbr 210 ------- 1 30.0 2.27 58 19217
d 6.07922 1 2 cbr 210 ------- 1 30.0 2.27 58 19217
- 6.0793 0 1 cbr 210 ------- 1 28.0 2.25 114 19298

I want to extract the lines with :

($8==1 && $3==1 && $4==2 && $1=="d" ){ print $1 ,$2 } -->this is file1 
($8==2 && $3==1 && $4==2 && $1=="d" ){ print $1 ,$2 } --> this is file2

Then, File one would be something like ;

 
d 6.07922 
 

Then I need to calculate number of occerrance of "d" for each set of time . Time increment period is 0.1. such 6.1--6.2--6.3,....

So number of occureence for each interval of time..EXPECTED output:

0.1 1
0.2 5
0.3 10
0.4 7
.. ..

The challange for me ..is how to make all of this in one script file....

Best Regards,
Mohd

awk '($3==1 && $4==2 && $1=="d" ){ print $1 ,$2 > "File" $8 }' infile

Then how you get the right number, such as 1,5, 10, 7?

0.1 1
0.2 5
0.3 10
0.4 7

Yes, The numbers are number of occurrence of "d" for each period of time for example (0.1-0.2)
so, if we calculate number of occurrence we can say " we have 5 "d" in period 0.2
and 10 "d" in 0.3 and so on>

0.1 1--> number of occurrence 
0.2 5--> number of occurrence 
0.3 10 ->number of occurrence 
0.4 7 --> number of occurrence 

Best Regards,
Moe

awk ' { v=int($2 * 10)/10+0.1; C[v]++ ; max=v>max?v:max; }
END { for(i=0.1;i<=max;i+=0.1) printf "%01.1f %d\n", i, C } ' file1