I have this large file that I need to go through using date and time.Every line in this file has a date and time in it.I need to search through the lines and get the lines that lie between two specific dates and times.Example file (the field for date and time is $2 and $3):  SERVER 2015-12-12 05:00:20 some_text_here something  SERVER 2015-11-02 12:22:40 some_text_here somethingSERVER 2015-12-11 20:00:00 some_text_here somethingSERVER 2015-12-11 23:00:00 some_text_here somethingSERVER 2015-12-12 00:30:00 some_text_here somethingSERVER 2015-12-12 00:59:00 some_text_here somethingSERVER 2015-09-20 03:28:11 some_text_here somethingSERVER 2015-04-16 04:49:59 some_text_here somethingThe command I tried (users have to supply 4 arguments when running the script):AAA=$1 $2BBB=$3 $4awk '$2 $3>='$AAA' && $2 $3<='$BBB'' file.txt > newfile.txtI am using the lines above as a script but its not working.newfile.txt should contain (using arguments 2015-12-11 20:00:00 2015-12-12 01:00:00):SERVER 2015-12-11 20:00:00 some_text_here somethingSERVER 2015-12-11 23:00:00 some_text_here somethingSERVER 2015-12-12 00:30:00 some_text_here somethingSERVER 2015-12-12 00:59:00 some_text_here something
Get lines between two timestamps from a file
files;awk;date;timestamps;time
Maybe you need a script that you can input the two specific dates and times.Code:#!/bin/bashif [ $# -ne 4 ];thenexit 0fiAAA=$1 $2BBB=$3 $4awk -v begintime=${AAA} -v endtime=${BBB} '$2 $3>=begintime && $2 $3<=endtime' exa > newfile.txt