title: grouping numbers by intervals: I have an array of numbers between 0.0-3.6
body: <p>I have an array of numbers between 0.0-3.6, I want to know how many of those numbers are in the interval: 0.0-0.2, 0.2-0.4 and so on, somebody can help me? thanks a lot...
  I tried in fortran this:</p>
  
  <pre><code>IMPLICIT NONE
  
  INTEGER :: acoun, bcoun, ccoun, dcoun, ecoun, fcoun, gcoun, hcoun, icoun 
  INTEGER ::  jcoun,  kcoun,  lcoun,  mcoun,  ncoun,  ocoun,  pcoun,  qcoun, ia
  INTEGER :: i1(4), i2(30), i3(30), i4(30), i5(30), i6(30), i7(30), i8(30), i9(30), i10(30), &amp;
  i11(30), i12(30), i13(30), i14(30), i15(30), i16(30), i17(30)
  REAL    :: a
  
  OPEN(UNIT=10,FILE='DAN1',STATUS='OLD')
  
  acoun=0.0
  bcoun=0.0
  ccoun=0.0
  dcoun=0.0
  ecoun=0.0
  fcoun=0.0
  gcoun=0.0
  hcoun=0.0
  icoun=0.0
  jcoun=0.0
  kcoun=0.0
  lcoun=0.0
  mcoun=0.0
  ncoun=0.0
  ocoun=0.0
  pcoun=0.0
  do i=1,119
  READ(10,*)a
   if (( a &lt; 0.2d0 ).and.(a &gt; 0.0d0) )then
      i1(acoun)=i
      acoun=acoun+1
   elseif (( a &lt; 0.4d0 ).and.(a &gt; 0.2d0) )then
      i2(bcoun)=i
      bcoun=bcoun+1
   elseif (( a &lt; 0.6d0 ).and.(a &gt; 0.4d0) )then
      i3(ccoun)=i
      ccoun=ccoun+1
   elseif (( a &lt; 0.8d0 ).and.(a &gt; 0.6d0) )then
      i4(dcoun)=i
      dcoun=dcoun+1
   elseif (( a &lt; 1.0d0 ).and.(a &gt; 0.8d0) )then
      i5(ecoun)=i
      ecoun=ecoun+1
   elseif (( a &lt; 1.2d0 ).and.(a &gt; 1.0d0) )then
      i6(fcoun)=i
      fcoun=fcoun+1
   elseif (( a &lt; 1.4d0 ).and.(a &gt; 1.2d0) )then
      i7(gcoun)=i
      gcoun=gcoun+1
   elseif (( a &lt; 1.6d0 ).and.(a &gt; 1.4d0) )then
      i8(hcoun)=i
      hcoun=hcoun+1
   elseif (( a &lt; 1.8d0 ).and.(a &gt; 1.6d0) )then
      i9(icoun)=i
      icoun=icoun+1     elseif (( a &lt; 2.0d0 ).and.(a &gt; 1.8d0) )then
      i10(jcoun)=i
      jcoun=jcoun+1
   elseif (( a &lt; 2.2d0 ).and.(a &gt; 2.0d0) )then
      i11(kcoun)=i
      kcoun=kcoun+1
   elseif (( a &lt; 2.4d0 ).and.(a &gt; 2.2d0) )then
      i12(lcoun)=i
      lcoun=lcoun+1
   elseif (( a &lt; 2.6d0 ).and.(a &gt; 2.4d0) )then
      i13(mcoun)=i
      mcoun=mcoun+1
   elseif (( a &lt; 2.8d0 ).and.(a &gt; 2.6d0) )then
      i14(ncoun)=i
      ncoun=ncoun+1
   elseif (( a &lt; 3.0d0 ).and.(a &gt; 2.8d0) )then
      i15(ocoun)=i
      ocoun=ocoun+1
   elseif (( a &lt; 3.2d0 ).and.(a &gt; 3.0d0) )then
      i16(pcoun)=i
      pcoun=pcoun+1
   elseif (a &gt; 3.2d0)then
      i17(qcoun)=i
      qcoun=qcoun+1
   endif
  enddo
       WRITE(*,*)  i1(acoun),acoun
   WRITE(*,*)  i2(bcoun),bcoun
   WRITE(*,*)  i3(ccoun),ccoun
   WRITE(*,*)  i4(dcoun),dcoun
   WRITE(*,*)  i5(ecoun),ecoun
   WRITE(*,*)  i6(fcoun),fcoun
   WRITE(*,*)  i7(gcoun),gcoun
   WRITE(*,*)  i8(hcoun),hcoun
   WRITE(*,*)  i9(icoun),icoun
   WRITE(*,*) i10(jcoun),jcoun
   WRITE(*,*) i11(kcoun),kcoun
   WRITE(*,*) i12(lcoun),lcoun
   WRITE(*,*) i13(mcoun),mcoun
   WRITE(*,*) i14(ncoun),ncoun
   WRITE(*,*) i15(ocoun),ocoun
   WRITE(*,*) i16(pcoun),pcoun
   WRITE(*,*) i17(qcoun),qcoun
  
  close(10)
  
  ENDPROGRAM sorting"
  </code></pre>
  
  <p>this file give some values but they are not correct this program overcount in each interval.</p>
  
  <p>and I tried this in bash</p>
  
  <p>I tried in bash using if statements like:</p>
  
  <pre><code>if [$var &gt; 0.0 -a 0.2 &lt; $var]then 
  echo "$var" &gt;&gt; file
  wc -l file
  </code></pre>
  
  <p>but it did not work also</p>
  
  <p>THANKS A LOT for some help.....</p>