im having trouble tou remove some specific lines from a file, but its not that simple. Tthe problem asks to search and then save the lines from a specific date and hour for example 2008-06-08
and 12:40:53.90 AM
until the date that the user wants which is a read variable input $dayy
. The real issue is that i want the lines that is greater after 12:40:53
until that if the $dayy
is for example 2008-06-12
i need the lines that exist before the specific time 12:40:53.90
, exactly after 4 days. i used the bash code below and with the last awk command i wanted to remove the lines that are in that day ($dayy
) and their time are after the 12:40:53.90
but it removes all the lines in that date. if you could help i will really appreciate that.
for example if the initial day is 2008-06-08
(spec_date
) and time 12:40:53.90
(timee
) then i want all the lines from that day, time until the SAME time in two days 2008-06-10
(dayy
)
read dayy ; read spec_date ; read timee ;
awk -v dayy $dayy -v spec_date=$spec_date -v timee=$timee '{ if($1 >=spec_date && $2>=timee && $1 <= dayy) print $0}' ex1.dat > ex2.dat
awk -v dayy=$dayy '! ( $1==dayy && $2 ="[12-23]:[0-59]:[0-59].[0-50]")' ex2.dat
example of my data
2008-06-08 12:40:53.90
2008-06-08 12:43:39.80
.......................
2008-06-11 **12:39:34.22**
2008-06-11 13:21:23:43