Estou tentando resumir essa lista para conter apenas cinco dias de dados, de hoje até cinco dias atrás. Eu tentei usar awk
, mas sem sucesso. Não há necessidade de se ater ao awk também. Esta é a saída:
Este é o meu código awk
para pesquisar por today's
date em uma linha:
awk -F " " -v todate="$(date +%Y-%m-%d)" 'todate' output.txt
Este é o meu código de loop while:
while read line
do
if (("$(date +%Y-%m-%d)" in $line))
then
echo $line
done < output.txt
Este é o arquivo output.txt
:
2018-05-09 14:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-10 03:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-10 16:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-11 05:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-11 18:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-12 07:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-12 20:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-13 09:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-13 22:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-14 11:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-15 00:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-15 08:00:00 UTC+0800;swlt;;BKP_USGSN03_OLP_MK8;CXS101289_R73B13(001-00-12)
2018-05-15 08:00:00 UTC+0800;sau;;2025,licensed_sau_normal;CXS101289_R73B13(001-00-12)
2018-05-15 08:00:00 UTC+0800;sau_lte;;1025,licensed_sau_lte_normal;CXS101289_R73B13(001-00-12)
2018-05-15 08:00:00 UTC+0800;pdp;;2001,licensed_pdp_normal;CXS101289_R73B13(001-00-12)
2018-05-15 13:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-16 02:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-16 15:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-17 04:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-17 17:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-18 06:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-18 19:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-19 08:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-19 21:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-20 10:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-20 23:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-21 12:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-22 01:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-22 14:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)
2018-05-23 03:40:22 UTC+0800;sau;;less_than_100,heartbeat;CXS101289_R73B13(001-00-12)