G'day rinkish85,
Firstly, I concur with what others have said regarding making no effort. This is the third question you've posted; and the third time you've just provided some sort of spec and expected others to do your work for you. Please read "How (Not) To Ask A Question", paying particular attention to the "Do Your Own Work" section. Then read "How do I post a question effectively?" and "SSCCE" to learn how to improve your posts.
The following is not a canned solution; it justs shows a technique that might be useful for you. You'll need to get your start and end dates into a canonical format (which may be different to what I've used). You'll need to handle your own I/O (see open if you don't know how to do that). If you're unfamiliar with the 'r' modifier, see "Non-destructive substitution"; and, if your version of Perl is earlier than 5.14, you'll need an intermediary variable to hold the original value of each record.
Here's the script showing the technique:
#!/usr/bin/env perl use 5.014; use warnings; my ($start, $end) = qw{20180201 20180206}; while (<DATA>) { my $date = s/^.*?(\d{2})\/(\d{2})\/(\d{4})\s*$/$3$2$1/r; next unless $date ge $start && $date le $end; print; } __DATA__ DQ94JD84 S8G2H A9X946N 111.222.333.123 HOME - [01/Feb/2018:01 +:08:39 -0800] 01/02/2018 XA29EN35 M4C6M D7F577Q 111.222.333.123 AWAY - [02/Feb/2018:01 +:08:39 -0800] 02/02/2018 JK20TQ67 K1L0V T6Z148X 111.222.333.123 HOME - [03/Feb/2018:01 +:08:39 -0800] 03/02/2018 SO78NZ28 B5S8J W9F920Z 111.222.333.123 HOME - [04/Feb/2018:01 +:08:39 -0800] 04/02/2018 BI55SY64 R6P5H A9U757R 111.222.333.123 HOME - [05/Feb/2018:01 +:08:39 -0800] 05/02/2018 MH72RG27 Y6X0N C7E352J 111.222.333.123 HOME - [01/Feb/2018:01 +:08:39 -0800] 01/02/2018 ET43US76 F5S3W X2L870O 111.222.333.123 HOME - [06/Feb/2018:01 +:08:39 -0800] 06/02/2018 QA43MM82 Y3K0O H8E229P 111.222.333.123 HOME - [11/Feb/2018:01 +:08:39 -0800] 11/02/2018 MK72HI41 A6W2I M3X402D 111.222.333.123 HOME - [15/Feb/2018:01 +:08:39 -0800] 15/02/2018 LJ28XY72 E0Z4L E8W757S 111.222.333.123 HOME - [22/Mar/2018:01 +:08:39 -0800] 22/03/2018 TJ47EG77 W5J6A A7L557Q 111.222.333.123 HOME - [01/Feb/2018:01 +:08:39 -0800] 01/02/2018 TJ47EG78 E6L8Z J4X329P 216.142.233.73 - - [30/Nov/2018:00:03: +08 -0500] 30/11/2018 TJ47EG79 N2V1H Q1Y615G 10.101.128.66 - - [03/Apr/2018:00:42:1 +1 -0500] 03/04/2018
Here's the output after running that script:
DQ94JD84 S8G2H A9X946N 111.222.333.123 HOME - [01/Feb/2018:01 +:08:39 -0800] 01/02/2018 XA29EN35 M4C6M D7F577Q 111.222.333.123 AWAY - [02/Feb/2018:01 +:08:39 -0800] 02/02/2018 JK20TQ67 K1L0V T6Z148X 111.222.333.123 HOME - [03/Feb/2018:01 +:08:39 -0800] 03/02/2018 SO78NZ28 B5S8J W9F920Z 111.222.333.123 HOME - [04/Feb/2018:01 +:08:39 -0800] 04/02/2018 BI55SY64 R6P5H A9U757R 111.222.333.123 HOME - [05/Feb/2018:01 +:08:39 -0800] 05/02/2018 MH72RG27 Y6X0N C7E352J 111.222.333.123 HOME - [01/Feb/2018:01 +:08:39 -0800] 01/02/2018 ET43US76 F5S3W X2L870O 111.222.333.123 HOME - [06/Feb/2018:01 +:08:39 -0800] 06/02/2018 TJ47EG77 W5J6A A7L557Q 111.222.333.123 HOME - [01/Feb/2018:01 +:08:39 -0800] 01/02/2018
— Ken
In reply to Re: extract lines from file between date range.
by kcott
in thread extract lines from file between date range.
by rinkish85
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |