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 something
SERVER 2015-12-11 20:00:00 some_text_here something
SERVER 2015-12-11 23:00:00 some_text_here something
SERVER 2015-12-12 00:30:00 some_text_here something
SERVER 2015-12-12 00:59:00 some_text_here something
SERVER 2015-09-20 03:28:11 some_text_here something
SERVER 2015-04-16 04:49:59 some_text_here something
The command I tried (users have to supply 4 arguments when running the script):
AAA="$1 $2"
BBB="$3 $4"
awk '$2" "$3>="'"$AAA"'" && $2" "$3<="'"$BBB"'"' file.txt > newfile.txt
I 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 something
SERVER 2015-12-11 23:00:00 some_text_here something
SERVER 2015-12-12 00:30:00 some_text_here something
SERVER 2015-12-12 00:59:00 some_text_here something

newfile.txtand which lines you do see innewfile.txt?newfile.txtas none of these lines satisfies the condition. Or which of this lines satisfies the condition in your opinion (please tell me the line or line number from you example above)?