I have this file in my server that i need to get a specific range of rows using specified dates so i searched for a script and come up with this.
19 Sep 2018 08:47:57,153#ad****#L****#2018-Sep-19 08:47:43 110#2018-Sep-19
08:47:57 153#14.***sec
19 Sep 2018 09:00:25,582#jg****#L****#2018-Sep-19 09:00:22 658#2018-Sep-19
09:00:25 582#2.***sec
19 Sep 2018 09:00:25,720#lr****#L****#2018-Sep-19 09:00:22 038#2018-Sep-19
09:00:25 720#3.***sec
....
I entered this command in the command line and it works well:
awk '$0 >= "19 Sep 2018 09:00:00" && $0 <= "19 Sep 2018 09:05:00"
'/home/../k../g../somelogfile.txt
but when i manipulate it in the script and put variables in it there is no output.
todayl=$(date --date="19 Sept 2018 09:00:00AM")
t_i_f_o=$(date +"%d %b %Y %H:%M:%S" --date="$today")
t_f_m_a=$(date +"%d %b %Y %H:%M:%S" --date="$today + 5 minutes")
awk '$0 >= "$t_i_f_o" && $0 <= "$t_f_m_a" ' /home/m.../k.../t.../somelogfile1.txt > /home/m.../k.../t../f.../another1.txt #Tried this
awk '$0 >= "${t_i_f_o}" && $0 <= "${t_f_m_a}"' /home/m.../k.../t.../somefile2.txt > /home/m.../k.../t.../f.../another2.txt # and this
when i look at the output file which is another1.txt and another2.txt there is no data. is there something wrong with the way i place my variable?