I have the file calls.txt. It has 7 fields:
Date|time|duration|callee|caller|calleeLocation|callerLocation
01/01/2005|15:55:27|495|10000075|10000029|29|4
01/01/2005|11:04:00|597|10000064|10000078|25|4
01/01/2005|08:44:06|593|10000070|10000107|1|7
01/01/2005|18:35:19|235|10000017|10000036|7|14
I want some help me to do the following methods:
- that will print the caller who has called 10000027 more than anybody else 
- that will the caller who has called 10000027 longer than anybody else(using duration field). 
- how many calls 10000027 has made between 1st April 2005 and 31st April 2005 
I tried some methods, but they don't do what I desire. This is my code:
#!/bin/bash
exec 401<> calls.txt 
while read line <&401      # read a line at a time from calls.txt
do                         # if end of file reached, while will yield false the$
{
full_line=$line;       # because $line is going to change, store it somewhe$
    date=${line%%|*}; # cut off the rest of $line but keep date 
    line=${line#*|};       
    time=${line%%|*}; # cut off the rest of $line but keep time
    line=${line#*|};       
    duration=${line%%|*};  # cut off the rest of $line but keep box
    line=${line#*|};       
    callee=${line%%|*};   # cut off the rest of $line but keep callee
    line=${line#*|};      
    caller=${line%%|*};   # cut off the rest of $line but keep caller
    line=${line#*|};      
    calleeLoc=${line%%|*};   # cut off the rest of $line but keep callee location
    line=${line#*|};
    callerLoc=${line%%|*};   # cut off the rest of $line but keep caller location
    line=${line#*|};
this method is supposed to print the caller who has called 10000027 most
    if [ $callee = 10000027 ]
     then  
       count= $(grep -cw $caller {callee}calls.txt
              if [[ $max_count -le $count ]] 
                 then
                max_count=$count;
                most_caller=$caller;
              fi
   fi  
how can i modify this method so that it print the caller who has the highest duration time among those who called 10000027
 if [ $callee = 10000027 ]
     then  
       count= $(grep -cw $caller {callee}calls.txt
              if [[ $max_count -le $count ]] 
                 then
                duration=$count;
                longest_caller=$caller;
              fi
   fi  
how can i modify this method so that it print how many calls made by 10000027 between 1st april 2005 and 31st april 2005
   if [ $caller = 10000027 ];
      then
            if [ $date -gt (1/4/2005) && $date -lt (31/4/2005) ];
                  $awk '$4~/10000027/{++c} END{ print c} 'FS=:calls.txt
            fi
    fi
}
done
exec 401>&-
 
     
     
    