Thanks for your solution but it's work only for my example.
For example if I choose time range between 15:40:00 and 23:10:00
this solution doens't work
Thanks a lot for this very nice solution
I have a lot of work to undestand in depth your code
#!/usr/bin/perl
@divs=qw(hour min sec milis); # the names of the time parts I'm grabbing
@start{@divs} = $ARGV[0]=~/(\d+)/g; # throw the first four digit groups into a hash naming them by the keys in @div
@end{@divs} = $ARGV[1]=~/(\d+)/g; # As above but the second argument to the script
#open (DATA, '<', "$ARGV[2]"); # if you were supplying a logfile as an argument to the command
while(<DATA>){
@time{@divs} = $_ =~/(\d+):/g; # as above, but for each line of the log file.
# the record time is after start time and not after end time for the window we are looking for.
if ((after(\%time, \%start)) && (! after(\%time, \%end))){ # see below for how after works the "\%" passes references to the hashes
print ; # print out the line
}
}
sub after{ # boolean check to see if a time is after a given limit
my ($time,$limit)=@_; # the arguments supplied
for (@divs){ # go through the keys in order
if ($time->{$_} < $limit->{$_}){
return 0; # if the first non-equal division (hour min sec milli) is less than the limit then this is not after the time
}
elsif ($time->{$_} > $limit->{$_}){
return 1; # the other case
}
}
return 1; # millisecond equivalent, display it
}
__DATA__
10:02:23:124.id_0000.1:"blalba"
10:05:26:124.id_0000.1:"blalba"
10:10:32:124.id_0000.1:"blalba"
11:32:36:124.id_0000.1:"blalba"
11:33:49:124.id_0000.1:"blalba"
11:36:23:124.id_0000.1:"blalba"
12:10:21:124.id_0000.1:"blalba"
12:20:21:124.id_0000.1:"blalba"
12:30:21:124.id_0000.1:"blalba"
If you used the open command to access the log file in ARGV[2]
I'm not sure that an awk command will give you a neater solution, however I'm frequently amazed at what some people manage to get awk to do on this site, though I do wonder if they can see what and how it is doing 6 months later